Compare commits

2 Commits

Author SHA1 Message Date
Lee
45a0a4332e test 2024-12-27 13:49:04 +00:00
Lee
9089767dc5 test 2024-12-27 13:48:53 +00:00
124 changed files with 1797 additions and 666 deletions

View File

@ -1,5 +1,5 @@
# Stage 1: Build the application
FROM maven:3.9.9-eclipse-temurin-17-alpine AS builder
FROM 3.9.9-eclipse-temurin-21-alpine AS builder
# Set the working directory
WORKDIR /home/container

50
pom.xml
View File

@ -16,57 +16,31 @@
<description>Bat Bot for Discord</description>
<properties>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>
<!-- Build Config -->
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Used for compiling the source code with the proper Java version -->
<!-- Spring -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- Enable incremental builds, this is reversed due to -->
<!-- a bug as seen in https://issues.apache.org/jira/browse/MCOMPILER-209 -->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<!-- Handles shading of dependencies in the final output jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<id>build-info</id>
<goals>
<goal>shade</goal>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<description>${project.description}</description>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
<!-- Specify the apps main class -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>cc.fascinated.bat.BatApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -3,7 +3,7 @@ package cc.fascinated.bat.afk;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.afk.command.AfkCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
*/
@Component
public class AfkFeature extends Feature {
public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public AfkFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("AFK", FeatureProfile.FeatureState.DISABLED, true);
registerCommand(commandService, context.getBean(AfkCommand.class));

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.afk.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.MemberUtils;
import cc.fascinated.bat.afk.profile.AfkProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -3,7 +3,7 @@ package cc.fascinated.bat.autorole;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.autorole.command.AutoRoleCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
@Component
public class AutoRoleFeature extends Feature {
@Autowired
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Auto Role", FeatureProfile.FeatureState.DISABLED, true);
registerCommand(commandService, context.getBean(AutoRoleCommand.class));

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.RoleUtils;
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import net.dv8tion.jda.api.Permission;
import org.springframework.context.ApplicationContext;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.autorole.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;

View File

@ -16,7 +16,7 @@ import cc.fascinated.bat.base.commands.server.channel.ChannelCommand;
import cc.fascinated.bat.base.commands.server.feature.FeatureCommand;
import cc.fascinated.bat.base.commands.utility.PastebinCommand;
import cc.fascinated.bat.base.commands.utility.lookup.LookupCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -28,7 +28,7 @@ import org.springframework.stereotype.Component;
@Component
public class BaseFeature extends Feature {
@Autowired
public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public BaseFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Base", FeatureProfile.FeatureState.ENABLED, false);
super.registerCommand(commandService, context.getBean(PremiumCommand.class));
@ -38,7 +38,6 @@ public class BaseFeature extends Feature {
super.registerCommand(commandService, context.getBean(VoteCommand.class));
super.registerCommand(commandService, context.getBean(PingCommand.class));
super.registerCommand(commandService, context.getBean(InviteCommand.class));
super.registerCommand(commandService, context.getBean(HelpCommand.class));
super.registerCommand(commandService, context.getBean(BotStatsCommand.class));
super.registerCommand(commandService, context.getBean(BannerCommand.class));
super.registerCommand(commandService, context.getBean(AvatarCommand.class));

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.botadmin;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.base.commands.botadmin.premium.PremiumRemoveSubCommand;
import cc.fascinated.bat.base.commands.botadmin.premium.PremiumSetSubCommand;
import lombok.NonNull;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.botadmin.premium;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.premium.PremiumProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.botadmin.premium;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.premium.PremiumProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.fun;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import lombok.NonNull;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.fun;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.fun;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.MathUtils;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.fun.image;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.fun.image;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.fun.image;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.fun.image;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.fun.image;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.*;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,127 +0,0 @@
package cc.fascinated.bat.base.commands.general;
import cc.fascinated.bat.Consts;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.InteractionBuilder;
import cc.fascinated.bat.event.EventListener;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.service.CommandService;
import lombok.NonNull;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author Fascinated (fascinated7)
*/
@Component
@CommandInfo(
name = "help",
description = "View the bots command categories",
userInstall = true,
category = Category.GENERAL
)
public class HelpCommand extends BatCommand implements EventListener {
private final CommandService commandService;
@Autowired
public HelpCommand(@NonNull CommandService commandService) {
this.commandService = commandService;
}
@Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) {
InteractionBuilder interactionBuilder = new InteractionBuilder();
interactionBuilder.addUrlButton("Invite Me", Consts.INVITE_URL, null);
interactionBuilder.addUrlButton("Support Server", Consts.SUPPORT_INVITE_URL, null);
interactionBuilder.addStringSelect("Home", "Return Home", Emojis.HOME_EMOJI, (buttonEvent) -> {
buttonEvent.editMessageEmbeds(createHomeEmbed(event.isFromGuild())).queue();
});
for (Category category : Category.getSortedByName()) {
List<BatCommand> categoryCommands = commandService.getCommandsByCategory(category, event.isFromGuild());
if (categoryCommands.isEmpty()) {
continue;
}
interactionBuilder.addStringSelect(
category.getName(),
"View commands in the %s category".formatted(category.getName()),
category.getEmoji(),
(buttonEvent) -> {
DescriptionBuilder description = new DescriptionBuilder(null);
description.appendLine("Commands in the **%s** Category".formatted(category.getName()), false);
description.emptyLine();
for (BatCommand command : categoryCommands) {
if (!command.getSubCommands().isEmpty()) {
for (BatCommand subCommand : command.getSubCommands().values()) {
description.appendLine("`%s %s` - %s".formatted(
command.getInfo().getName(),
subCommand.getInfo().getName(),
subCommand.getInfo().getDescription()
), true);
}
continue;
}
description.appendLine("`%s` - %s".formatted(
command.getInfo().getName(),
command.getInfo().getDescription()
), true);
}
buttonEvent.editMessageEmbeds(EmbedUtils.genericEmbed()
.setDescription(description.build())
.build()).queue();
});
}
event.replyEmbeds(createHomeEmbed(event.isFromGuild())).addComponents(interactionBuilder.build()).queue();
}
/**
* Creates the home embed for the help command
*
* @return The home embed
*/
private MessageEmbed createHomeEmbed(boolean ranInsideGuild) {
StringBuilder categories = new StringBuilder();
for (Category category : Category.values()) {
if (commandService.getCommandsByCategory(category, ranInsideGuild).isEmpty()) {
continue;
}
long commandCount = commandService.getCommandsByCategory(category, ranInsideGuild).size();
categories.append("➜ %s - **%s Command%s**\n".formatted(
category.getName(),
commandCount,
commandCount == 1 ? "" : "s"
));
}
return EmbedUtils.genericEmbed()
.setDescription("""
**Welcome to the Bat Help Menu!**%s
%s
*View our [TOS](%s) and [Privacy Policy](%s) for more information.*
""".formatted(
!ranInsideGuild ? "\n*guild only commands won't be shown here*" : "",
categories.toString(),
Consts.TERMS_OF_SERVICE_URL,
Consts.PRIVACY_POLICY_URL
))
.build();
}
}

View File

@ -1,9 +1,9 @@
package cc.fascinated.bat.base.commands.general;
import cc.fascinated.bat.Consts;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.service.DiscordService;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.avatar;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.avatar;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.avatar;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.banner;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.banner;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.general.banner;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.NumberFormatter;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.server.channel;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.channel;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.channel;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.channel;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.feature;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.feature;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.server.feature;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import net.dv8tion.jda.api.Permission;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.server.feature;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.utility;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.PasteUtils;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.base.commands.utility.lookup;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.base.commands.utility.lookup;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -6,7 +6,7 @@ import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.birthday.command.BirthdayCommand;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import cc.fascinated.bat.service.DiscordService;
import cc.fascinated.bat.service.GuildService;
import lombok.NonNull;
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
public class BirthdayFeature extends Feature implements EventListener {
private final GuildService guildService;
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService) {
super("Birthday", FeatureProfile.FeatureState.DISABLED, true);
this.guildService = guildService;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TextChannelUtils;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.birthday.UserBirthday;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.birthday.UserBirthday;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.birthday.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.birthday.UserBirthday;
import cc.fascinated.bat.birthday.profile.BirthdayProfile;

View File

@ -0,0 +1,140 @@
package cc.fascinated.bat.command;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author Braydon
*/
@Setter@Getter
public abstract class BatCommand extends ListenerAdapter implements IBatCommand {
/**
* The snowflake of this command, if it
* was successfully registered on Discord.
*/
private Long snowflake;
/**
* The data for this command.
*/
@NonNull private final SlashCommandData commandData;
/**
* The category of this command.
*/
@NonNull private final CommandCategory category;
/**
* The sub-commands for this command.
*/
@NonNull private final List<BatSubCommand> subCommands = Collections.synchronizedList(new ArrayList<>());
public BatCommand(@NonNull String name, @NonNull String description, @NonNull CommandCategory category, @NonNull OptionData... options) {
this(name, description, category, DefaultMemberPermissions.ENABLED, options);
}
public BatCommand(@NonNull String name, @NonNull String description, @NonNull CommandCategory category, @NonNull DefaultMemberPermissions defaultPermissions, @NonNull OptionData... options) {
commandData = Commands.slash(name, description)
.setDefaultPermissions(defaultPermissions)
.addOptions(options);
this.category = category;
}
/**
* Get the name of this command.
*
* @return the command name
*/
@Override @NonNull
public String getName() {
return commandData.getName();
}
/**
* Get the full name of this command.
*
* @return the full name
*/
@Override @NonNull
public String getFullName() {
return getName();
}
/**
* Get the description of this command.
*
* @return the command description
*/
@Override @NonNull
public String getDescription() {
return commandData.getDescription();
}
/**
* Get the mentionable name of this command.
*
* @return the mentionable name
*/
@Override @NonNull
public final String getMentionable() {
return "</%s:%s>".formatted(getName(), getSnowflake());
}
/**
* Register a sub-command to this command.
*
* @param subCommand the sub-command to register
*/
protected final void withSubCommand(@NonNull BatSubCommand subCommand) {
subCommands.add(subCommand);
// Add the sub-command to the command data
if (subCommand.getGroupName() == null) { // No command group
getCommandData().addSubcommands(subCommand.getCommandData());
} else {
// Add to any existing command group, otherwise create a new one
for (SubcommandGroupData subCommandGroup : getCommandData().getSubcommandGroups()) {
if (subCommand.getGroupName().equals(subCommandGroup.getName())) {
subCommandGroup.addSubcommands(subCommand.getCommandData());
return;
}
}
getCommandData().addSubcommandGroups(new SubcommandGroupData(
subCommand.getGroupName(),
"The " + subCommand.getGroupName() + " group for /" + getName() + " " + subCommand.getName()
).addSubcommands(subCommand.getCommandData()));
}
}
/**
* Get a sub-command by name.
*
* @param group the sub-command group, null if none
* @param name the sub-command name
* @return the sub-command, null if not found
*/
public final BatSubCommand getSubCommand(String group, @NonNull String name) {
for (BatSubCommand subCommand : subCommands) {
String commandGroup = subCommand.getGroupName();
// Check if groups match (both null or both equal)
boolean groupsMatch = (group == null && commandGroup == null) ||
(commandGroup != null && commandGroup.equals(group));
if (subCommand.getName().equals(name) && groupsMatch) {
return subCommand;
}
}
return null;
}
}

View File

@ -0,0 +1,82 @@
package cc.fascinated.bat.command;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
/**
* A sub-command for a {@link BatCommand}.
*
* @author Braydon
*/
@Setter @Getter
public abstract class BatSubCommand implements IBatCommand {
/**
* The parent of this sub-command.
*/
@NonNull private final BatCommand parent;
/**
* The snowflake of this sub=command, if it
* was successfully registered on Discord.
*/
private Long snowflake;
/**
* The full name of this command, including the
* parent name, category, and sub-command name.
*/
private String fullName;
/**
* The optional group name for this sub-command.
*/
private final String groupName;
/**
* The data for this sub-command.
*/
@NonNull private final SubcommandData commandData;
public BatSubCommand(@NonNull BatCommand parent, @NonNull String name, @NonNull String description, @NonNull OptionData... options) {
this(parent, null, name, description, options);
}
public BatSubCommand(@NonNull BatCommand parent, String groupName, @NonNull String name, @NonNull String description, @NonNull OptionData... options) {
this.parent = parent;
this.groupName = groupName;
commandData = new SubcommandData(name, description).addOptions(options);
}
/**
* Get the name of this command.
*
* @return the command name
*/
@Override @NonNull
public String getName() {
return commandData.getName();
}
/**
* Get the description of this command.
*
* @return the command description
*/
@Override @NonNull
public String getDescription() {
return commandData.getDescription();
}
/**
* Get the mentionable name of this command.
*
* @return the mentionable name
*/
@Override @NonNull
public final String getMentionable() {
return "</%s:%s>".formatted(getFullName(), getSnowflake());
}
}

View File

@ -0,0 +1,25 @@
package cc.fascinated.bat.command;
import lombok.Getter;
import lombok.NonNull;
import net.dv8tion.jda.api.entities.emoji.Emoji;
/**
* The categories of {@link BatCommand}'s.
*
* @author Braydon
*/
@Getter
public enum CommandCategory {
GENERAL("⚙️"),
GUILD("🏠");
/**
* The emoji for this category.
*/
@NonNull private final Emoji emoji;
CommandCategory(@NonNull String unicode) {
emoji = Emoji.fromUnicode(unicode);
}
}

View File

@ -0,0 +1,97 @@
package cc.fascinated.bat.command;
import cc.fascinated.bat.common.EnumUtils;
import cc.fascinated.bat.common.InteractionResponder;
import cc.fascinated.bat.common.model.BatGuild;
import lombok.NonNull;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.Command;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* A base Rufus command.
*
* @author Braydon
*/
public interface IBatCommand {
/**
* Get the name of this command.
*
* @return the command name
*/
@NonNull String getName();
/**
* Get the full name of this command.
*
* @return the full name
*/
@NonNull String getFullName();
/**
* Get the description of this command.
*
* @return the command description
*/
@NonNull String getDescription();
/**
* Get the mentionable name of this command.
*
* @return the mentionable name
*/
@NonNull String getMentionable();
/**
* Fired when this command is executed.
* <p>
* If this command has {@link BatSubCommand}'s, this
* will not be invoked for the parent, and instead only
* for the sub-commands.
* </p>
*
* @param guild the ticket guild that executed this command
* @param discordGuild the Discord guild that executed this command
* @param member the member that executed this command
* @param responder the responder to the interaction
* @param event the event that triggered this command
*/
default void execute(@NonNull BatGuild guild, @NonNull Guild discordGuild, @NonNull Member member, @NonNull InteractionResponder responder, @NonNull SlashCommandInteractionEvent event) {
event.deferReply().queue(); // Thinking by default
}
/**
* Auto complete this command.
*
* @param guild the ticket guild that executed this command
* @param discordGuild the Discord guild that executed this command
* @param member the member that executed this command
* @param event the event that triggered this auto completion
* @return the choices to auto complete
*/
@NonNull
default List<Command.Choice> autoComplete(@NonNull BatGuild guild, @NonNull Guild discordGuild, @NonNull Member member, @NonNull CommandAutoCompleteInteractionEvent event) {
return List.of();
}
/**
* Get the choices for an enum.
*
* @param enumClass the enum class to get the choices for
* @return the enum choices
* @param <T> the enum type
*/
@NonNull
default <T extends Enum<T>> List<Command.Choice> getEnumChoices(@NonNull Class<T> enumClass) {
return Arrays.stream(enumClass.getEnumConstants())
.map(constant -> new Command.Choice(EnumUtils.getEnumName(constant), constant.name()))
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,16 @@
package cc.fascinated.bat.command.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Commands annotated with this will only
* be executable by the bot owner.
*
* @author Braydon
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface BotOwner { }

View File

@ -0,0 +1,16 @@
package cc.fascinated.bat.command.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Commands annotated with this will send
* "thinking..." message when executed.
*
* @author Braydon
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Thinking {}

View File

@ -0,0 +1,186 @@
package cc.fascinated.bat.command.command;
import cc.fascinated.bat.common.BatEmoji;
import cc.fascinated.bat.common.Colors;
import cc.fascinated.bat.common.InteractionResponder;
import cc.fascinated.bat.common.MiscUtils;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.DiscordService;
import jakarta.annotation.Nonnull;
import lombok.NonNull;
import cc.fascinated.bat.command.CommandCategory;
import cc.fascinated.bat.command.IBatCommand;
import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.BatSubCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
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;
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.info.BuildProperties;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author Braydon
*/
public final class HelpCommand extends BatCommand {
private static final String CATEGORY_DROPDOWN_ID = "select-category";
private static final String MAIN_MENU_BUTTON_ID = "main-help-menu";
/**
* The command service to use for the registry.
*/
@NonNull private final CommandService commandService;
/**
* The build properties for this app, null if not available.
*/
private final BuildProperties buildProperties;
public HelpCommand(@NonNull CommandService commandService, BuildProperties buildProperties) {
super("helpbob", "View the commands for Rufus", CommandCategory.GENERAL);
this.commandService = commandService;
this.buildProperties = buildProperties;
}
/**
* Fired when this command is executed.
* <p>
* If this command has {@link BatSubCommand}'s, this
* will not be invoked for the parent, and instead only
* for the sub-commands.
* </p>
*
* @param guild the ticket guild that executed this command
* @param discordGuild the Discord guild that executed this command
* @param member the member that executed this command
* @param responder the responder to the interaction
* @param event the event that triggered this command
*/
@Override
public void execute(@NonNull BatGuild guild, @NonNull Guild discordGuild, @NonNull Member member, @NonNull InteractionResponder responder, @NonNull SlashCommandInteractionEvent event) {
responder.reply(true, buildMainMenu(member, discordGuild), buildMainMenuComponents(discordGuild).toArray(new LayoutComponent[0])).queue();
}
@Override
public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent event) {
// Switch to the selected category
if (event.getComponentId().equals(CATEGORY_DROPDOWN_ID)) {
event.editMessageEmbeds(buildCategoryEmbed(Objects.requireNonNull(event.getMember()), CommandCategory.valueOf(event.getSelectedOptions().getFirst().getValue())))
.setComponents(
ActionRow.of(buildCategoryMenu()),
ActionRow.of(Button.primary(MAIN_MENU_BUTTON_ID, "Main Menu").withEmoji(Emoji.fromUnicode("🏠")))
).queue();
}
}
@Override
public void onButtonInteraction(@NotNull ButtonInteractionEvent event) {
// Switch to the main menu
if (event.getComponentId().equals(MAIN_MENU_BUTTON_ID)) {
event.editMessageEmbeds(buildMainMenu(Objects.requireNonNull(event.getMember()),
Objects.requireNonNull(event.getGuild()))).setComponents(buildMainMenuComponents(event.getGuild())).queue();
}
}
/**
* Build the embed for the main menu.
*
* @param member the member to build for
* @param discordGuild the discord guild
* @return the main menu
*/
@NonNull
private MessageEmbed buildMainMenu(@NonNull Member member, @NonNull Guild discordGuild) {
String categoryNames = Arrays.stream(CommandCategory.values())
.map(category -> "- **%s Commands**: `%s`".formatted(MiscUtils.capitalize(category.name()), commandService.getCommands(member, category).size()))
.collect(Collectors.joining("\n"));
// Send the help menu
return new EmbedBuilder()
.setColor(Colors.DEFAULT)
.setTitle(BatEmoji.RUFUS + " Rufus Help Menu")
.setDescription(MiscUtils.arrayToString(
"Rufus is a smart and efficient Discord bot that streamlines ticket management for your server. With a focus on simplicity and responsiveness, Rufus helps your staff team handle support requests, bug reports, and general inquiries with ease.",
"",
"Here are my commands:",
categoryNames,
"",
"To get a list of commands for an individual category, select it from the dropdown below. Interested and wanna use me in your server? [Invite Me](" + MiscUtils.getInviteUrl(discordGuild.getJDA()) + ")!"
)).setFooter("Rufus v%s".formatted(buildProperties == null ? "0" : buildProperties.getVersion())).build();
}
/**
* Build the components for the main menu.
*
* @param guild the guild to use for the JDA instance
* @return the components
*/
@NonNull
private List<LayoutComponent> buildMainMenuComponents(@NonNull Guild guild) {
return Arrays.asList(
ActionRow.of(buildCategoryMenu()),
ActionRow.of(
Button.link("https://rufus.rainnny.club", "Support Server").withEmoji(Emoji.fromUnicode("🏠")),
Button.link(MiscUtils.getInviteUrl(guild.getJDA()), "Invite Me").withEmoji(Emoji.fromUnicode("🤖"))
)
);
}
/**
* Build the dropdown menu for categories.
*
* @return the category dropdown menu
*/
@NonNull
private StringSelectMenu buildCategoryMenu() {
StringSelectMenu.Builder categoryDropdown = StringSelectMenu.create(CATEGORY_DROPDOWN_ID).setPlaceholder("👉🏼 Select a category...");
for (CommandCategory category : CommandCategory.values()) {
categoryDropdown.addOption(MiscUtils.capitalize(category.name()) + " Commands", category.name(), category.getEmoji());
}
return categoryDropdown.build();
}
/**
* Build the embed for the category menu.
*
* @param member the member to build for
* @param category the category to build for
* @return the category menu
*/
@NonNull
private MessageEmbed buildCategoryEmbed(@NonNull Member member, @NonNull CommandCategory category) {
// Build the command list
StringBuilder commands = new StringBuilder();
for (IBatCommand command : commandService.getCommands(member, category)) {
// Skip parents that have sub-commands
if (command instanceof BatCommand parentCommand && !parentCommand.getSubCommands().isEmpty()) {
continue;
}
commands.append("- ").append(command.getMentionable()).append(" - ").append(command.getDescription()).append("\n");
}
// Build the embed
return new EmbedBuilder()
.setColor(Colors.DEFAULT)
.setTitle(category.getEmoji().getFormatted() + " " + MiscUtils.capitalize(category.name()) + " Commands")
.setDescription(MiscUtils.arrayToString(
"Here are the commands for the " + MiscUtils.capitalize(category.name()) + " category:",
"",
commands.toString()
)).setFooter("Rufus v%s".formatted(buildProperties == null ? "0" : buildProperties.getVersion())).build();
}
}

View File

@ -0,0 +1,44 @@
package cc.fascinated.bat.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
/**
* Emojis used by Rufus.
*
* @author Braydon
*/
@AllArgsConstructor @RequiredArgsConstructor @Getter
public enum BatEmoji {
RUFUS("rufus", "1319317309608689674"),
LOADING("loading", "1319483685787013212", true),
SUCCESS("success", "1319483459781132410"),
CROSS("cross", "1319483437928677446");
/**
* The name of this emoji.
*/
@NonNull private final String name;
/**
* The ID of this emoji.
*/
@NonNull private final String id;
/**
* Whether this emoji is animated.
*/
private boolean animated;
/**
* Get the formatted emoji.
*
* @return the formatted emoji
*/
@Override @NonNull
public String toString() {
return (animated ? "<a:" : "<:") + name + ":" + id + ">";
}
}

View File

@ -0,0 +1,294 @@
package cc.fascinated.bat.common;
import cc.fascinated.bat.Consts;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.components.LayoutComponent;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction;
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
import java.awt.*;
/**
* A simple utility class to make
* responding to interactions easier.
*
* @author Braydon
*/
@AllArgsConstructor
public final class InteractionResponder {
/**
* The interaction event to respond to.
*/
@NonNull private final IReplyCallback event;
/**
* Respond to the interaction with a generic embed.
*
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @return the reply action
*/
@NonNull
public RestAction<Message> replyGenericEmbed(@NonNull String content, Object... args) {
return replyGenericEmbed(content, args, (LayoutComponent[]) null);
}
/**
* Respond to the interaction with a generic embed.
*
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> replyGenericEmbed(@NonNull String content, Object[] args, LayoutComponent... components) {
return replyGenericEmbed(false, content, args, components);
}
/**
* Respond to the interaction with a generic embed.
*
* @param ephemeral whether the message should be ephemeral
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @return the reply action
*/
@NonNull
public RestAction<Message> replyGenericEmbed(boolean ephemeral, @NonNull String content, Object... args) {
return replyGenericEmbed(ephemeral, content, args, (LayoutComponent[]) null);
}
/**
* Respond to the interaction with a generic embed.
*
* @param ephemeral whether the message should be ephemeral
* @param content the content to respond with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> replyGenericEmbed(boolean ephemeral, @NonNull String content, LayoutComponent... components) {
return replyGenericEmbed(ephemeral, content, null, components);
}
/**
* Respond to the interaction with a generic embed.
*
* @param ephemeral whether the message should be ephemeral
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> replyGenericEmbed(boolean ephemeral, @NonNull String content, Object[] args, LayoutComponent... components) {
content = format(content, args);
return reply(ephemeral, buildGenericEmbed(content, args), components);
}
/**
* Build a generic embed.
*
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @return the embed
*/
@NonNull
public MessageEmbed buildGenericEmbed(@NonNull String content, Object... args) {
content = format(content, args);
return new EmbedBuilder()
.setColor(Colors.DEFAULT)
.setDescription(format(content, args))
.build();
}
/**
* Respond to the interaction with a success embed.
*
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @return the reply action
*/
@NonNull
public RestAction<Message> replySuccess(@NonNull String content, Object... args) {
return replySuccess(false, content, args);
}
/**
* Respond to the interaction with a success embed.
*
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> replySuccess(@NonNull String content, Object[] args, LayoutComponent... components) {
return replySuccess(false, content, args, components);
}
/**
* Respond to the interaction with a success embed.
*
* @param ephemeral whether the message should be ephemeral
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @return the reply action
*/
@NonNull
public RestAction<Message> replySuccess(boolean ephemeral, @NonNull String content, Object... args) {
return replySuccess(ephemeral, content, args, (LayoutComponent[]) null);
}
/**
* Respond to the interaction with a success embed.
*
* @param ephemeral whether the message should be ephemeral
* @param content the content to respond with
* @param args the optional arguments to format the content with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> replySuccess(boolean ephemeral, @NonNull String content, Object[] args, LayoutComponent... components) {
content = format(content, args);
return reply(ephemeral, new EmbedBuilder()
.setColor(Color.GREEN)
.setDescription(BatEmoji.SUCCESS + " " + content)
.build(), components);
}
/**
* Respond to the interaction with an error embed.
*
* @param error the error to respond with
* @param args the optional arguments to format the error with
* @return the reply action
*/
@NonNull
public RestAction<Message> replyError(@NonNull String error, Object... args) {
return replyError(false, error, args);
}
/**
* Respond to the interaction with an error embed.
*
* @param ephemeral whether the message should be ephemeral
* @param error the error to respond with
* @param args the optional arguments to format the error with
* @return the reply action
*/
@NonNull
public RestAction<Message> replyError(boolean ephemeral, @NonNull String error, Object... args) {
error = format(error, args);
return reply(ephemeral, new EmbedBuilder()
.setColor(Color.RED)
.setDescription(BatEmoji.CROSS + " " + error)
.build());
}
/**
* Respond to the interaction with an embed.
*
* @param embed the embed to respond with
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(@NonNull MessageEmbed embed) {
return reply(false, embed);
}
/**
* Respond to the interaction with an embed.
*
* @param embed the embed to respond with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(@NonNull MessageEmbed embed, LayoutComponent... components) {
return reply(false, embed, components);
}
/**
* Respond to the interaction with an embed.
*
* @param ephemeral whether the message should be ephemeral
* @param embed the embed to respond with
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(boolean ephemeral, @NonNull MessageEmbed embed) {
return reply(ephemeral, embed, (LayoutComponent[]) null);
}
/**
* Respond to the interaction with an embed.
*
* @param ephemeral whether the message should be ephemeral
* @param embed the embed to respond with
* @param components the optional components to add to the message
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(boolean ephemeral, @NonNull MessageEmbed embed, LayoutComponent... components) {
boolean hasComponents = components != null && (components.length > 0);
if (event.isAcknowledged()) {
WebhookMessageCreateAction<Message> action = event.getHook()
.setEphemeral(ephemeral)
.sendMessageEmbeds(embed);
return hasComponents ? action.setComponents(components) : action;
}
ReplyCallbackAction action = event.replyEmbeds(embed).setEphemeral(ephemeral);
return (hasComponents ? action.setComponents(components) : action).flatMap(InteractionHook::retrieveOriginal);
}
/**
* Respond to the interaction with a message.
*
* @param content the message to respond with
* @param args the optional arguments to format the message with
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(@NonNull String content, Object... args) {
return reply(false, content, args);
}
/**
* Respond to the interaction with a message.
*
* @param ephemeral whether the message should be ephemeral
* @param content the message to respond with
* @param args the optional arguments to format the message with
* @return the reply action
*/
@NonNull
public RestAction<Message> reply(boolean ephemeral, @NonNull String content, Object... args) {
content = format(content, args);
if (event.isAcknowledged()) {
return event.getHook().setEphemeral(ephemeral).sendMessage(content);
}
return event.reply(content).setEphemeral(ephemeral).flatMap(InteractionHook::retrieveOriginal);
}
/**
* Format the given content with the given arguments.
*
* @param content the content to format
* @param args the arguments to format with
* @return the formatted content
*/
@NonNull
private String format(@NonNull String content, Object... args) {
return args != null && (args.length > 0) ? content.formatted(args) : content;
}
}

View File

@ -0,0 +1,96 @@
package cc.fascinated.bat.common;
import lombok.NonNull;
import lombok.experimental.UtilityClass;
import net.dv8tion.jda.api.JDA;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
@UtilityClass
public final class MiscUtils {
/**
* Get the invite url for the bot.
*
* @param jda the JDA instance
* @return the invite url
*/
@NonNull
public static String getInviteUrl(@NonNull JDA jda) {
return "https://discord.com/oauth2/authorize?client_id=" + jda.getSelfUser().getId();
}
/**
* Convert an array of strings to a single string.
*
* @param lines the lines to convert
* @return the string
*/
@NonNull
public static String arrayToString(String... lines) {
return Arrays.stream(lines)
.filter(Objects::nonNull)
.collect(Collectors.joining("\n"));
}
/**
* Capitalize the first letter of
* every word in the given string.
*
* @param input the input to capitalize
* @return the capitalized string
*/
@NonNull
public static String capitalize(@NonNull String input) {
input = input.toLowerCase().replace('_', ' ');
StringBuilder result = new StringBuilder();
boolean capitalizeNext = true;
for (char character : input.toCharArray()) {
if (Character.isSpaceChar(character)) {
capitalizeNext = true;
result.append(character);
} else if (capitalizeNext) {
result.append(Character.toUpperCase(character));
capitalizeNext = false;
} else {
result.append(character);
}
}
return result.toString();
}
/**
* Get the enum constant with the given
* name from the given enum class.
*
* @param enumClass the enum class
* @param enumName the enum name
* @param <T> the enum type
* @return the enum constant, null if not found
*/
public static <T extends Enum<T>> T getEnum(@NonNull Class<T> enumClass, String enumName) {
return getEnum(enumClass, enumName, null);
}
/**
* Get the enum constant with the given
* name from the given enum class.
*
* @param enumClass the enum class
* @param enumName the enum name
* @param defaultValue the default value
* @param <T> the enum type
* @return the enum constant, default value if not found
*/
public static <T extends Enum<T>> T getEnum(@NonNull Class<T> enumClass, String enumName, T defaultValue) {
if (enumName == null) {
return defaultValue;
}
try {
return Enum.valueOf(enumClass, enumName);
} catch (IllegalArgumentException ex) {
return defaultValue;
}
}
}

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.common.feature;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.service.OldCommandService;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@ -35,7 +35,7 @@ public abstract class Feature {
* @param commandService The command service
* @param command The command to register
*/
public void registerCommand(@NonNull CommandService commandService, @NonNull BatCommand command) {
public void registerCommand(@NonNull OldCommandService commandService, @NonNull BatCommand command) {
command.setFeature(this);
for (BatCommand subCommand : command.getSubCommands().values()) {
subCommand.setFeature(this);

View File

@ -1,4 +1,4 @@
package cc.fascinated.bat.common.command;
package cc.fascinated.bat.common.oldcommand;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,4 +1,4 @@
package cc.fascinated.bat.common.command;
package cc.fascinated.bat.common.oldcommand;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package cc.fascinated.bat.common.command;
package cc.fascinated.bat.common.oldcommand;
import net.dv8tion.jda.api.Permission;

View File

@ -1,4 +1,4 @@
package cc.fascinated.bat.common.command;
package cc.fascinated.bat.common.oldcommand;
import lombok.AccessLevel;
import lombok.Getter;

View File

@ -3,7 +3,7 @@ package cc.fascinated.bat.counter;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.counter.command.CounterCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
@Component
public class CounterFeature extends Feature {
@Autowired
public CounterFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public CounterFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Counter", FeatureProfile.FeatureState.DISABLED, true);
super.registerCommand(commandService, context.getBean(CounterCommand.class));

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.counter.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import net.dv8tion.jda.api.Permission;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.counter.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.NumberFormatter;
import cc.fascinated.bat.counter.CounterChannel;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.counter.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.counter.CounterChannel;
import cc.fascinated.bat.counter.CounterProfile;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.counter.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.counter.CounterChannel;
import cc.fascinated.bat.counter.CounterProfile;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.counter.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.counter.CounterProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -3,7 +3,7 @@ package cc.fascinated.bat.leveling;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.leveling.command.LevelingCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -23,7 +23,7 @@ public class LevelingFeature extends Feature {
public static final Map<Integer, Double> xpRequiredCache = new HashMap<>();
@Autowired
public LevelingFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public LevelingFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Leveling", FeatureProfile.FeatureState.DISABLED, true);
super.registerCommand(commandService, context.getBean(LevelingCommand.class));

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.leveling.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.leveling.LevelingProfile;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.leveling.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.NumberFormatter;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.leveling.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.leveling.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.leveling.LevelingProfile;
import cc.fascinated.bat.leveling.UserLevel;

View File

@ -7,7 +7,7 @@ import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.logging.command.LogsCommand;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.DiscordMessage;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
@ -27,7 +27,7 @@ public class LogFeature extends Feature {
public static LogFeature INSTANCE;
@Autowired
public LogFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public LogFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Logging", FeatureProfile.FeatureState.DISABLED, true);
INSTANCE = this;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.logging.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.InteractionBuilder;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.logging.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import net.dv8tion.jda.api.Permission;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.logging.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.logging.LogCategory;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.logging.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.logging.LogCategory;

View File

@ -7,7 +7,7 @@ import cc.fascinated.bat.messagesnipe.command.MessageSnipeCommand;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.common.model.DiscordMessage;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -31,7 +31,7 @@ public class MessageSnipeFeature extends Feature implements EventListener {
private static final long SNIPED_MESSAGE_EXPIRATION = TimeUnit.HOURS.toMillis(1);
@Autowired
public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public MessageSnipeFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Message Snipe", FeatureProfile.FeatureState.DISABLED, true);
super.registerCommand(commandService, context.getBean(MessageSnipeCommand.class));

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.messagesnipe.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.messagesnipe.MessageSnipeFeature;
import cc.fascinated.bat.common.model.BatGuild;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.messagesnipe.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.PasteUtils;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.messagesnipe.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import lombok.NonNull;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

View File

@ -8,7 +8,7 @@ import cc.fascinated.bat.moderation.punish.Punishment;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;
import cc.fascinated.bat.common.model.BatGuild;
import cc.fascinated.bat.common.model.BatUser;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import cc.fascinated.bat.service.DiscordService;
import cc.fascinated.bat.service.GuildService;
import cc.fascinated.bat.service.UserService;
@ -37,7 +37,7 @@ public class ModerationFeature extends Feature implements EventListener {
private final UserService userService;
@Autowired
public ModerationFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService,
public ModerationFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService, @NonNull GuildService guildService,
@NonNull UserService userService) {
super("Moderation", FeatureProfile.FeatureState.DISABLED, true);
this.guildService = guildService;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TimeUtils;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;
import cc.fascinated.bat.moderation.punish.PunishmentType;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TimeUtils;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.moderation.punish.Punishment;

View File

@ -1,8 +1,8 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.Category;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.Category;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.DescriptionBuilder;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.NumberFormatter;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.moderation.punish.Punishment;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.moderation.punish.Punishment;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;

View File

@ -1,7 +1,7 @@
package cc.fascinated.bat.moderation.command;
import cc.fascinated.bat.common.command.BatCommand;
import cc.fascinated.bat.common.command.CommandInfo;
import cc.fascinated.bat.common.oldcommand.BatCommand;
import cc.fascinated.bat.common.oldcommand.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.moderation.punish.PunishmentProfile;
import cc.fascinated.bat.moderation.punish.PunishmentType;

View File

@ -3,7 +3,7 @@ package cc.fascinated.bat.namehistory;
import cc.fascinated.bat.common.feature.Feature;
import cc.fascinated.bat.common.feature.FeatureProfile;
import cc.fascinated.bat.namehistory.command.NameHistoryCommand;
import cc.fascinated.bat.service.CommandService;
import cc.fascinated.bat.service.OldCommandService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -17,7 +17,7 @@ public class NameHistoryFeature extends Feature {
public static final int NAME_HISTORY_SIZE = 25;
@Autowired
public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull OldCommandService commandService) {
super("Name History", FeatureProfile.FeatureState.DISABLED, true);
super.registerCommand(commandService, context.getBean(NameHistoryCommand.class));

Some files were not shown because too many files have changed in this diff Show More