Skip to content

Commit

Permalink
Add safety check
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCdry committed Sep 1, 2024
1 parent 283a838 commit 3fe91da
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.clementraynaud.skoice.storage.config.ConfigField;
import net.clementraynaud.skoice.tasks.UpdateNetworksTask;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.kyori.adventure.text.event.HoverEvent;
Expand Down Expand Up @@ -101,7 +102,9 @@ private void setup(Player tokenManager) {
this.plugin.getBot().getMenuFactory().loadAll(this.plugin);

this.plugin.getBot().getJDA().getGuilds().forEach(guild -> {
if (guild.getSelfMember().hasPermission(Permission.ADMINISTRATOR)) {
if (guild.getSelfMember().hasPermission(Permission.ADMINISTRATOR)
&& (guild.getRequiredMFALevel() != Guild.MFALevel.TWO_FACTOR_AUTH
|| this.plugin.getBot().getJDA().getSelfUser().isMfaEnabled())) {
guild.getPublicRole().getManager().givePermissions(Permission.USE_APPLICATION_COMMANDS).queue();
}
});
Expand Down

0 comments on commit 3fe91da

Please sign in to comment.