forked from Fascinated/Bat
fix admin cmds
This commit is contained in:
parent
a7dc517a36
commit
deb656086a
@ -1,10 +1,7 @@
|
||||
package cc.fascinated.bat.service;
|
||||
|
||||
import cc.fascinated.bat.Consts;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.BatCommandExecutor;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.*;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
@ -78,7 +75,8 @@ public class CommandService extends ListenerAdapter {
|
||||
|
||||
// Unregister all commands that Discord has but we don't
|
||||
jda.retrieveCommands().complete().forEach(command -> {
|
||||
if (commands.containsKey(command.getName()) && commands.get(command.getName()).getCommandInfo().category().isHidden()) {
|
||||
CommandInfo commandInfo = commands.get(command.getName()).getCommandInfo();
|
||||
if (commands.containsKey(command.getName()) && (commandInfo.category().isHidden() || commandInfo.botOwnerOnly())) {
|
||||
jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord
|
||||
log.info("Unregistered hidden command \"{}\" from Discord", command.getName());
|
||||
return;
|
||||
@ -107,7 +105,7 @@ public class CommandService extends ListenerAdapter {
|
||||
|
||||
Objects.requireNonNull(jda.getGuildById(Consts.ADMIN_GUILD), "Admin guild is null!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
.updateCommands().addCommands(commands.values().stream()
|
||||
.filter(command -> !command.getCategory().isHidden() || !command.isBotOwnerOnly())
|
||||
.filter(command -> command.getCategory().isHidden() || command.isBotOwnerOnly())
|
||||
.map(BatCommand::getCommandData).toList()).complete();
|
||||
|
||||
log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);
|
||||
|
Loading…
Reference in New Issue
Block a user