Skip to content

Commit

Permalink
Fix NPE in GuildRoleUpdateHandler (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 authored Nov 26, 2021
1 parent 0e972b2 commit 8cc5675
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RoleUpdateIconEvent extends GenericRoleUpdateEvent<RoleIcon>
{
public static final String IDENTIFIER = "icon";

public RoleUpdateIconEvent(@Nonnull JDA api, long responseNumber, @Nonnull Role role, @Nonnull RoleIcon oldIcon)
public RoleUpdateIconEvent(@Nonnull JDA api, long responseNumber, @Nonnull Role role, @Nullable RoleIcon oldIcon)
{
super(api, responseNumber, role, oldIcon, role.getIcon(), IDENTIFIER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public RoleTags getTags()
return tags == null ? RoleTagsImpl.EMPTY : tags;
}

@Nonnull
@Nullable
@Override
public RoleIcon getIcon()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ protected Long handleInternally(DataObject content)
}

RoleIcon oldIcon = role.getIcon();
if (!Objects.equals(oldIcon.getIconId(), iconId) || !Objects.equals(oldIcon.getEmoji(), emoji))
RoleIcon newIcon = iconId == null && emoji == null
? null
: new RoleIcon(iconId, emoji, roleId);
if (!Objects.equals(oldIcon, newIcon))
{
if (iconId == null && emoji == null)
role.setIcon(null);
else
role.setIcon(new RoleIcon(iconId, emoji, roleId));
role.setIcon(newIcon);
getJDA().handleEvent(
new RoleUpdateIconEvent(
getJDA(), responseNumber,
Expand Down

0 comments on commit 8cc5675

Please sign in to comment.