re-impl help cmd and fix cmd categories
Some checks failed
Deploy to Dokku / docker (ubuntu-latest) (push) Has been cancelled
Some checks failed
Deploy to Dokku / docker (ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@ -3,7 +3,7 @@ package cc.fascinated.bat.features.base;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand;
|
||||
import cc.fascinated.bat.features.base.commands.discord.LookupUserCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.LookupUserCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.EightBallCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.*;
|
||||
@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
public class BaseFeature extends Feature {
|
||||
@Autowired
|
||||
public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("Base", false, Category.GENERAL);
|
||||
super("Base", false);
|
||||
|
||||
super.registerCommand(commandService, context.getBean(PremiumCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -18,7 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "8ball", description = "Ask the magic 8ball a question", guildOnly = false, userInstall = true)
|
||||
@CommandInfo(name = "8ball", description = "Ask the magic 8ball a question", guildOnly = false, userInstall = true, category = Category.FUN)
|
||||
public class EightBallCommand extends BatCommand {
|
||||
private final String[] responses = new String[]{
|
||||
"It is certain",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
@ -26,7 +27,7 @@ import java.lang.management.RuntimeMXBean;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "botstats", description = "Shows the bot statistics", guildOnly = false, userInstall = true)
|
||||
@CommandInfo(name = "botstats", description = "Shows the bot statistics", guildOnly = false, userInstall = true, category = Category.GENERAL)
|
||||
public class BotStatsCommand extends BatCommand {
|
||||
private final GuildService guildService;
|
||||
private final UserService userService;
|
||||
|
@ -16,6 +16,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.LayoutComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
@ -27,12 +28,13 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "help", description = "View the bots command categories.", guildOnly = false)
|
||||
@CommandInfo(name = "help", description = "View the bots command categories.", guildOnly = false, category = Category.GENERAL)
|
||||
public class HelpCommand extends BatCommand implements EventListener {
|
||||
private final CommandService commandService;
|
||||
|
||||
@ -59,45 +61,44 @@ public class HelpCommand extends BatCommand implements EventListener {
|
||||
event.reply("Invalid category selected.").queue();
|
||||
return;
|
||||
}
|
||||
event.reply("hello this doesnt work yet").queue();
|
||||
|
||||
// StringBuilder commands = new StringBuilder();
|
||||
// List<BatCommand> categoryCommands = commandService.getCommandsByCategory(category, true);
|
||||
// if (categoryCommands.isEmpty()) {
|
||||
// commands = new StringBuilder("No commands available in this category.");
|
||||
// } else {
|
||||
// for (BatCommand command : categoryCommands) {
|
||||
// if (!command.getSubCommands().isEmpty()) {
|
||||
// for (Map.Entry<String, BatSubCommand> entry : command.getSubCommands().entrySet()) {
|
||||
// BatSubCommand subCommand = entry.getValue();
|
||||
// SubcommandData commandData = subCommand.getCommandData();
|
||||
// commands.append("</%s %s:%s> - %s\n".formatted(
|
||||
// command.getCommandInfo().name(),
|
||||
// commandData.getName(),
|
||||
// subCommand.getCommandSnowflake(),
|
||||
// commandData.getDescription()
|
||||
// ));
|
||||
// }
|
||||
// continue;
|
||||
// }
|
||||
// commands.append("</%s:%s> - %s\n".formatted(
|
||||
// command.getCommandInfo().name(),
|
||||
// command.getCommandSnowflake(),
|
||||
// command.getCommandInfo().description()
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int subCommands = categoryCommands.stream().mapToInt(command -> command.getSubCommands().size()).sum();
|
||||
// event.editMessageEmbeds(EmbedUtils.genericEmbed()
|
||||
// .setAuthor("%s Category".formatted(category.getName()))
|
||||
// .setDescription("%s command%s (with %s sub-command%s)\n\n**Commands:**\n%s".formatted(
|
||||
// categoryCommands.size(),
|
||||
// categoryCommands.size() == 1 ? "" : "s",
|
||||
// subCommands,
|
||||
// subCommands == 1 ? "" : "s",
|
||||
// commands.toString()
|
||||
// )).build()).queue();
|
||||
StringBuilder commands = new StringBuilder();
|
||||
List<BatCommand> categoryCommands = commandService.getCommandsByCategory(category);
|
||||
if (categoryCommands.isEmpty()) {
|
||||
commands = new StringBuilder("No commands available in this category.");
|
||||
} else {
|
||||
for (BatCommand command : categoryCommands) {
|
||||
if (!command.getSubCommands().isEmpty()) {
|
||||
for (Map.Entry<String, BatCommand> entry : command.getSubCommands().entrySet()) {
|
||||
BatCommand subCommand = entry.getValue();
|
||||
SubcommandData subcommandData = subCommand.getSubcommandData();
|
||||
commands.append("</%s %s:%s> - %s\n".formatted(
|
||||
command.getInfo().getName(),
|
||||
subcommandData.getName(),
|
||||
subCommand.getSnowflake(),
|
||||
subcommandData.getDescription()
|
||||
));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
commands.append("</%s:%s> - %s\n".formatted(
|
||||
command.getInfo().getName(),
|
||||
command.getSnowflake(),
|
||||
command.getInfo().getDescription()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
int subCommands = categoryCommands.stream().mapToInt(command -> command.getSubCommands().size()).sum();
|
||||
event.editMessageEmbeds(EmbedUtils.genericEmbed()
|
||||
.setAuthor("%s Category".formatted(category.getName()))
|
||||
.setDescription("%s command%s (with %s sub-command%s)\n\n**Commands:**\n%s".formatted(
|
||||
categoryCommands.size(),
|
||||
categoryCommands.size() == 1 ? "" : "s",
|
||||
subCommands,
|
||||
subCommands == 1 ? "" : "s",
|
||||
commands.toString()
|
||||
)).build()).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.Consts;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -16,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "invite", description = "Invite the bot to your server!", guildOnly = false)
|
||||
@CommandInfo(name = "invite", description = "Invite the bot to your server!", guildOnly = false, category = Category.GENERAL)
|
||||
public class InviteCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.discord;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
@ -22,7 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "lookupuser", description = "Lookup a user", userInstall = true)
|
||||
@CommandInfo(name = "lookupuser", description = "Lookup a user", userInstall = true, category = Category.GENERAL)
|
||||
public class LookupUserCommand extends BatCommand {
|
||||
public LookupUserCommand() {
|
||||
super.addOptions(new OptionData(OptionType.STRING, "id", "The id of the user", true));
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "ping", description = "Gets the ping of the bot", guildOnly = false, userInstall = true)
|
||||
@CommandInfo(name = "ping", description = "Gets the ping of the bot", guildOnly = false, userInstall = true, category = Category.GENERAL)
|
||||
public class PingCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedDescriptionBuilder;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
@ -16,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "vote", description = "Vote for the bot", guildOnly = false)
|
||||
@CommandInfo(name = "vote", description = "Vote for the bot", guildOnly = false, category = Category.GENERAL)
|
||||
public class VoteCommand extends BatCommand {
|
||||
private static final String[] VOTE_LINKS = new String[]{
|
||||
"https://top.gg/bot/1254161119975833652/vote",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
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 Nick (okNick)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "avatar", description = "View the avatar of the guild or a user", guildOnly = false)
|
||||
@CommandInfo(name = "avatar", description = "View the avatar of the guild or a user", guildOnly = false, category = Category.GENERAL)
|
||||
public class AvatarCommand extends BatCommand {
|
||||
@Autowired
|
||||
public AvatarCommand(@NonNull ApplicationContext context) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -16,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Component("avatar:guild.sub")
|
||||
@CommandInfo(name = "guild", description = "View the avatar of the guild")
|
||||
@CommandInfo(name = "guild", description = "View the avatar of the guild", category = Category.GENERAL)
|
||||
public class GuildSubCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -19,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Component("avatar:user.sub")
|
||||
@CommandInfo(name = "user", description = "View the avatar of a user", guildOnly = false)
|
||||
@CommandInfo(name = "user", description = "View the avatar of a user", guildOnly = false, category = Category.GENERAL)
|
||||
public class UserSubCommand extends BatCommand {
|
||||
public UserSubCommand() {
|
||||
super.addOptions(new OptionData(OptionType.USER, "user", "The user to view the avatar of", true));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
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 Nick (okNick)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "banner", description = "View the banner of the guild or a user", guildOnly = false)
|
||||
@CommandInfo(name = "banner", description = "View the banner of the guild or a user", guildOnly = false, category = Category.GENERAL)
|
||||
public class BannerCommand extends BatCommand {
|
||||
@Autowired
|
||||
public BannerCommand(@NonNull ApplicationContext context) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -16,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Component("banner:guild.sub")
|
||||
@CommandInfo(name = "guild", description = "View the banner of the guild")
|
||||
@CommandInfo(name = "guild", description = "View the banner of the guild", category = Category.GENERAL)
|
||||
public class GuildSubCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -20,7 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Component("banner:user.sub")
|
||||
@CommandInfo(name = "user", description = "View the banner of a user", guildOnly = false)
|
||||
@CommandInfo(name = "user", description = "View the banner of a user", guildOnly = false, category = Category.GENERAL)
|
||||
public class UserSubCommand extends BatCommand {
|
||||
public UserSubCommand() {
|
||||
super.addOptions(new OptionData(OptionType.USER, "user", "The user to view the banner of", true));
|
||||
|
Reference in New Issue
Block a user