forked from Fascinated/Bat
fix premiumadmin command
This commit is contained in:
parent
73e4b58695
commit
a7dc517a36
@ -37,6 +37,11 @@ public abstract class BatCommand implements BatCommandExecutor {
|
||||
*/
|
||||
private Category category;
|
||||
|
||||
/**
|
||||
* Whether the command can only be used by the bot owner
|
||||
*/
|
||||
private boolean botOwnerOnly;
|
||||
|
||||
/**
|
||||
* The command snowflake from Discord
|
||||
*/
|
||||
@ -45,6 +50,7 @@ public abstract class BatCommand implements BatCommandExecutor {
|
||||
public BatCommand() {
|
||||
this.commandInfo = getClass().getAnnotation(CommandInfo.class);
|
||||
this.category = this.commandInfo.category();
|
||||
this.botOwnerOnly = this.commandInfo.botOwnerOnly();
|
||||
|
||||
this.commandData = new CommandDataImpl(this.commandInfo.name(), this.commandInfo.description())
|
||||
.setGuildOnly(this.commandInfo.guildOnly());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.command.impl.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -11,7 +12,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true)
|
||||
@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true, category = Category.BOT_ADMIN)
|
||||
public class PremiumAdminCommand extends BatCommand {
|
||||
@Autowired
|
||||
public PremiumAdminCommand(@NonNull ApplicationContext context) {
|
||||
|
@ -94,7 +94,7 @@ public class CommandService extends ListenerAdapter {
|
||||
|
||||
// Register all commands
|
||||
List<Command> discordCommands = jda.updateCommands().addCommands(commands.values().stream()
|
||||
.filter(command -> !command.getCategory().isHidden())
|
||||
.filter(command -> !command.getCategory().isHidden() || !command.isBotOwnerOnly())
|
||||
.map(BatCommand::getCommandData).toList()).complete();
|
||||
for (Command discordCommand : discordCommands) {
|
||||
commands.get(discordCommand.getName()).setCommandSnowflake(discordCommand.getIdLong());
|
||||
@ -107,7 +107,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())
|
||||
.filter(command -> !command.getCategory().isHidden() || !command.isBotOwnerOnly())
|
||||
.map(BatCommand::getCommandData).toList()).complete();
|
||||
|
||||
log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before);
|
||||
|
Loading…
x
Reference in New Issue
Block a user