This commit is contained in:
Lee 2024-07-04 15:20:26 +01:00
parent d023e21575
commit 11299b3ca7
4 changed files with 6 additions and 9 deletions

@ -67,7 +67,7 @@ public abstract class BatCommand {
commandData = new CommandDataImpl(info.getName(), info.getDescription()) commandData = new CommandDataImpl(info.getName(), info.getDescription())
.setContexts(InteractionContextType.ALL) .setContexts(InteractionContextType.ALL)
.setIntegrationTypes(integrationTypes) .setIntegrationTypes(integrationTypes)
.setGuildOnly(info.isGuildOnly()); .setGuildOnly(!getInfo().isUserInstall() && getInfo().isGuildOnly());
} }
/** /**

@ -36,7 +36,7 @@ import java.util.Map;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "help", description = "View the bots command categories.", guildOnly = false, category = Category.GENERAL) @CommandInfo(name = "help", description = "View the bots command categories.", guildOnly = false, userInstall = true, category = Category.GENERAL)
public class HelpCommand extends BatCommand implements EventListener { public class HelpCommand extends BatCommand implements EventListener {
private final CommandService commandService; private final CommandService commandService;

@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "vote", description = "Vote for the bot", guildOnly = false, category = Category.GENERAL) @CommandInfo(name = "vote", description = "Vote for the bot", guildOnly = false, userInstall = true, category = Category.GENERAL)
public class VoteCommand extends BatCommand { public class VoteCommand extends BatCommand {
private static final String[] VOTE_LINKS = new String[]{ private static final String[] VOTE_LINKS = new String[]{
"https://top.gg/bot/1254161119975833652/vote", "https://top.gg/bot/1254161119975833652/vote",

@ -94,8 +94,7 @@ public class CommandService extends ListenerAdapter {
// Unregister all commands that Discord has but we don't // Unregister all commands that Discord has but we don't
jda.retrieveCommands().complete().forEach(command -> { jda.retrieveCommands().complete().forEach(command -> {
if (commands.containsKey(command.getName()) if (commands.containsKey(command.getName()) && commands.get(command.getName()).getInfo().isBotOwnerOnly()) {
&& commands.get(command.getName()).getInfo().isBotOwnerOnly()) {
jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord
log.info("Unregistered hidden command \"{}\" from Discord", command.getName()); log.info("Unregistered hidden command \"{}\" from Discord", command.getName());
return; return;
@ -109,8 +108,7 @@ public class CommandService extends ListenerAdapter {
}); });
// Register all commands // Register all commands
List<Command> discordCommands = jda.updateCommands().addCommands(commands.values().stream() List<Command> discordCommands = jda.updateCommands().addCommands(commands.values().stream().filter(command -> !command.getInfo().isBotOwnerOnly())
.filter(command -> !command.getInfo().isBotOwnerOnly())
.map(BatCommand::getCommandData).toList()).complete(); .map(BatCommand::getCommandData).toList()).complete();
for (Command discordCommand : discordCommands) { for (Command discordCommand : discordCommands) {
commands.get(discordCommand.getName()).setSnowflake(discordCommand.getIdLong()); commands.get(discordCommand.getName()).setSnowflake(discordCommand.getIdLong());
@ -121,8 +119,7 @@ public class CommandService extends ListenerAdapter {
} }
} }
if (adminGuild != null) { if (adminGuild != null) {
adminGuild.updateCommands().addCommands(commands.values().stream() adminGuild.updateCommands().addCommands(commands.values().stream().filter(command -> command.getInfo().isBotOwnerOnly())
.filter(command -> command.getInfo().isBotOwnerOnly())
.map(BatCommand::getCommandData).toList()).complete(); .map(BatCommand::getCommandData).toList()).complete();
} else { } else {
log.error("Unable to find the admin guild to register hidden commands"); log.error("Unable to find the admin guild to register hidden commands");