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

Fixed nullpointer exceptions for when doing owner checks #1146

Merged
merged 2 commits into from
Dec 3, 2019
Merged
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 @@ -48,9 +48,9 @@ public static boolean canInteract(Member issuer, Member target)
Guild guild = issuer.getGuild();
if (!guild.equals(target.getGuild()))
throw new IllegalArgumentException("Provided members must both be Member objects of the same Guild!");
if(guild.getOwner().equals(issuer))
if(issuer.isOwner())
return true;
if(guild.getOwner().equals(target))
if(target.isOwner())
return false;
List<Role> issuerRoles = issuer.getRoles();
List<Role> targetRoles = target.getRoles();
Expand Down Expand Up @@ -80,7 +80,7 @@ public static boolean canInteract(Member issuer, Role target)
Guild guild = issuer.getGuild();
if (!guild.equals(target.getGuild()))
throw new IllegalArgumentException("Provided Member issuer and Role target must be from the same Guild!");
if(guild.getOwner().equals(issuer))
if(issuer.isOwner())
return true;
List<Role> issuerRoles = issuer.getRoles();
return !issuerRoles.isEmpty() && canInteract(issuerRoles.get(0), target);
Expand Down Expand Up @@ -203,7 +203,7 @@ public static boolean canInteract(User issuer, Emote emote, MessageChannel chann
TextChannel text = (TextChannel) channel;
member = text.getGuild().getMemberById(issuer.getIdLong());
return emote.getGuild().equals(text.getGuild()) // within the same guild
|| (external && member.hasPermission(text, Permission.MESSAGE_EXT_EMOJI)); // in different guild
|| (external && member != null && member.hasPermission(text, Permission.MESSAGE_EXT_EMOJI)); // in different guild
default:
return external; // In Group or Private it only needs to be external
}
Expand Down