Fix discord permission issues with link module (#5197)

This commit is contained in:
Josh Roy 2022-12-27 16:07:47 -05:00 committed by GitHub
parent 0936fe80bd
commit ca71d93963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -198,7 +198,10 @@ public class DiscordSettings implements IConf {
}
public List<String> getCommandSnowflakes(String command) {
return config.getList("commands." + command + ".allowed-roles", String.class);
if (config.isList("commands." + command + ".allowed-roles")) {
return config.getList("commands." + command + ".allowed-roles", String.class);
}
return null;
}
public List<String> getCommandAdminSnowflakes(String command) {

View File

@ -56,7 +56,8 @@ public class InteractionControllerImpl extends ListenerAdapter implements Intera
event.deferReply(command.isEphemeral()).queue(null, failure -> logger.log(Level.SEVERE, "Error while deferring Discord command", failure));
final InteractionEvent interactionEvent = new InteractionEventImpl(event);
if (!DiscordUtil.hasRoles(event.getMember(), jda.getSettings().getCommandSnowflakes(command.getName()))) {
final List<String> commandSnowflakes = jda.getSettings().getCommandSnowflakes(command.getName());
if (commandSnowflakes != null && !DiscordUtil.hasRoles(event.getMember(), commandSnowflakes)) {
interactionEvent.reply(tl("noAccessCommand"));
return;
}