Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in GuildRoleUpdateHandler #1903

Merged
merged 2 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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