From 455c3f0bf141d7de12cfc602f24e46db11527677 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 26 Jun 2024 20:41:31 +0100 Subject: [PATCH] fix a bug --- .../java/cc/fascinated/bat/service/CommandService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index bc40395..9eeef9b 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -100,7 +100,8 @@ public class CommandService extends ListenerAdapter { if (command == null) { return; } - BatGuild guild = discordGuild != null ? guildService.getGuild(discordGuild.getId()) : null; + boolean ranInsideGuild = discordGuild != null; + BatGuild guild = ranInsideGuild ? guildService.getGuild(discordGuild.getId()) : null; BatUser user = userService.getUser(event.getUser().getId()); try { @@ -131,7 +132,7 @@ public class CommandService extends ListenerAdapter { } // Check if the user has the required permissions - if (discordGuild != null && event.getMember() != null) { + if (ranInsideGuild && event.getMember() != null) { List missingPermissions = new ArrayList<>(); for (Permission permission : requiredPermissions) { if (!event.getMember().hasPermission(permission)) { @@ -147,7 +148,7 @@ public class CommandService extends ListenerAdapter { return; } } - executor.execute(guild, user, guild != null ? event.getChannel().asTextChannel() : event.getChannel().asPrivateChannel(), + executor.execute(guild, user, ranInsideGuild ? event.getChannel().asTextChannel() : event.getChannel().asPrivateChannel(), event.getMember(), event.getInteraction()); } catch (Exception ex) { log.error("An error occurred while executing command \"{}\"", commandName, ex);