This commit is contained in:
parent
4d891e1825
commit
455c3f0bf1
@ -100,7 +100,8 @@ public class CommandService extends ListenerAdapter {
|
|||||||
if (command == null) {
|
if (command == null) {
|
||||||
return;
|
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());
|
BatUser user = userService.getUser(event.getUser().getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -131,7 +132,7 @@ public class CommandService extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user has the required permissions
|
// Check if the user has the required permissions
|
||||||
if (discordGuild != null && event.getMember() != null) {
|
if (ranInsideGuild && event.getMember() != null) {
|
||||||
List<Permission> missingPermissions = new ArrayList<>();
|
List<Permission> missingPermissions = new ArrayList<>();
|
||||||
for (Permission permission : requiredPermissions) {
|
for (Permission permission : requiredPermissions) {
|
||||||
if (!event.getMember().hasPermission(permission)) {
|
if (!event.getMember().hasPermission(permission)) {
|
||||||
@ -147,7 +148,7 @@ public class CommandService extends ListenerAdapter {
|
|||||||
return;
|
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());
|
event.getMember(), event.getInteraction());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("An error occurred while executing command \"{}\"", commandName, ex);
|
log.error("An error occurred while executing command \"{}\"", commandName, ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user