Compare commits
33 Commits
6f12062311
...
new-comman
Author | SHA1 | Date | |
---|---|---|---|
45a0a4332e | |||
9089767dc5 | |||
b3a6284e40 | |||
5f099a97f0 | |||
577c895169 | |||
6db2a01bb3 | |||
4cc4334df4 | |||
a4acdc2ec1 | |||
7ca984e785 | |||
53730a82cf | |||
6f4a787ccb | |||
2b588a5940 | |||
fe4cf3bbf4 | |||
ede931f994 | |||
d5ed2b0b13 | |||
4479bce0a4 | |||
3c80b3ca4b | |||
65fd68f76c | |||
6640dd4368 | |||
96cb634fd4 | |||
0f9a23e4a2 | |||
eb3d8eea29 | |||
7e45b5d880 | |||
892b85ccb4 | |||
f291344c45 | |||
df9b0e2604 | |||
2695a2994a | |||
fa50eb9873 | |||
58bb976f96 | |||
3615ef4b92 | |||
5c78ec907f | |||
c380878039 | |||
cfaa501377 |
2
.mvn/wrapper/maven-wrapper.properties
vendored
2
.mvn/wrapper/maven-wrapper.properties
vendored
@ -16,4 +16,4 @@
|
||||
# under the License.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Stage 1: Build the application
|
||||
FROM maven:3.9.8-eclipse-temurin-17-alpine AS builder
|
||||
FROM 3.9.9-eclipse-temurin-21-alpine AS builder
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /home/container
|
||||
@ -11,7 +11,7 @@ COPY . .
|
||||
RUN mvn package -q -Dmaven.test.skip -DskipTests -T2C
|
||||
|
||||
# Stage 2: Create the final lightweight image
|
||||
FROM eclipse-temurin:17.0.12_7-jre-focal
|
||||
FROM eclipse-temurin:17.0.13_11-jre-focal
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /home/container
|
||||
|
97
pom.xml
97
pom.xml
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.4.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -75,11 +49,6 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>fascinated-repo-public</id>
|
||||
<name>Fascinated's Repository</name>
|
||||
<url>https://repo.fascinated.cc/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -99,26 +68,7 @@
|
||||
<dependency>
|
||||
<groupId>io.sentry</groupId>
|
||||
<artifactId>sentry-spring-boot-starter-jakarta</artifactId>
|
||||
<version>7.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.mongock</groupId>
|
||||
<artifactId>mongock-bom</artifactId>
|
||||
<version>5.4.4</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.mongock</groupId>
|
||||
<artifactId>mongock-springboot-v3</artifactId>
|
||||
<version>5.4.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.mongock</groupId>
|
||||
<artifactId>mongodb-springdata-v4-driver</artifactId>
|
||||
<version>5.4.4</version>
|
||||
<scope>compile</scope>
|
||||
<version>7.16.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis for caching -->
|
||||
@ -160,25 +110,13 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.3.1</version>
|
||||
<version>5.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.jodah</groupId>
|
||||
<artifactId>expiringmap</artifactId>
|
||||
<version>0.5.11</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>se.michaelthelin.spotify</groupId>
|
||||
<artifactId>spotify-web-api-java</artifactId>
|
||||
<version>8.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.co.conoregan</groupId>
|
||||
<artifactId>themoviedbapi</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -186,11 +124,6 @@
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.mcutils</groupId>
|
||||
<artifactId>mcutils-java-library</artifactId>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Steppschuh</groupId>
|
||||
<artifactId>Java-Markdown-Generator</artifactId>
|
||||
|
@ -5,7 +5,6 @@ import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.service.EventService;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.mongock.runner.springboot.EnableMongock;
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@ -21,7 +20,6 @@ import java.util.Objects;
|
||||
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
@EnableMongock
|
||||
@Log4j2(topic = "Bat")
|
||||
public class BatApplication {
|
||||
public static Gson GSON = new GsonBuilder().create();
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.afk;
|
||||
package cc.fascinated.bat.afk;
|
||||
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.afk.command.AfkCommand;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
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.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));
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.afk;
|
||||
package cc.fascinated.bat.afk;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.afk;
|
||||
package cc.fascinated.bat.afk;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.springframework.stereotype.Component;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.afk.command;
|
||||
package cc.fascinated.bat.afk.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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.features.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.afk.profile.AfkProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.features.afk.profile;
|
||||
package cc.fascinated.bat.afk.profile;
|
||||
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.autorole;
|
||||
package cc.fascinated.bat.autorole;
|
||||
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.autorole.command.AutoRoleCommand;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
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.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));
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.autorole;
|
||||
package cc.fascinated.bat.autorole;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.autorole.command;
|
||||
package cc.fascinated.bat.autorole.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.autorole.profile.AutoRoleProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.features.autorole.profile;
|
||||
package cc.fascinated.bat.autorole.profile;
|
||||
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.Getter;
|
@ -1,21 +1,22 @@
|
||||
package cc.fascinated.bat.features.base;
|
||||
package cc.fascinated.bat.base;
|
||||
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.commands.botadmin.BotAdminCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.EightBallCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.PPSizeCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.*;
|
||||
import cc.fascinated.bat.features.base.commands.general.avatar.AvatarCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.banner.BannerCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.MemberCountCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.PremiumCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.channel.ChannelCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand;
|
||||
import cc.fascinated.bat.features.base.commands.utility.PastebinCommand;
|
||||
import cc.fascinated.bat.features.base.commands.utility.lookup.LookupCommand;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.base.commands.botadmin.BotAdminCommand;
|
||||
import cc.fascinated.bat.base.commands.fun.CoinFlipCommand;
|
||||
import cc.fascinated.bat.base.commands.fun.EightBallCommand;
|
||||
import cc.fascinated.bat.base.commands.fun.PPSizeCommand;
|
||||
import cc.fascinated.bat.base.commands.fun.image.ImageCommand;
|
||||
import cc.fascinated.bat.base.commands.general.*;
|
||||
import cc.fascinated.bat.base.commands.general.avatar.AvatarCommand;
|
||||
import cc.fascinated.bat.base.commands.general.banner.BannerCommand;
|
||||
import cc.fascinated.bat.base.commands.server.MemberCountCommand;
|
||||
import cc.fascinated.bat.base.commands.server.PremiumCommand;
|
||||
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.OldCommandService;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -27,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));
|
||||
@ -37,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));
|
||||
@ -47,5 +47,6 @@ public class BaseFeature extends Feature {
|
||||
super.registerCommand(commandService, context.getBean(LookupCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(PPSizeCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(PastebinCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(CoinFlipCommand.class));
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.base.commands.botadmin;
|
||||
package cc.fascinated.bat.base.commands.botadmin;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumRemoveSubCommand;
|
||||
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumSetSubCommand;
|
||||
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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.base.commands.botadmin.premium;
|
||||
package cc.fascinated.bat.base.commands.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
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;
|
||||
import cc.fascinated.bat.service.GuildService;
|
||||
import lombok.NonNull;
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.base.commands.botadmin.premium;
|
||||
package cc.fascinated.bat.base.commands.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
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;
|
||||
import cc.fascinated.bat.service.GuildService;
|
||||
import lombok.NonNull;
|
@ -0,0 +1,40 @@
|
||||
package cc.fascinated.bat.base.commands.fun;
|
||||
|
||||
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;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@CommandInfo(
|
||||
name = "coinflip",
|
||||
description = "Flips a coin",
|
||||
userInstall = true
|
||||
)
|
||||
@Component
|
||||
public class CoinFlipCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member,
|
||||
Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
||||
event.reply("%s, you flipped a coin and got **%s**!".formatted(user.getDiscordUser().getAsMention(), flip())).queue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips a coin
|
||||
*
|
||||
* @return The result of the coin flip
|
||||
*/
|
||||
public String flip() {
|
||||
return new Random().nextBoolean() ? "heads" : "tails";
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,13 +1,13 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun;
|
||||
package cc.fascinated.bat.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.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;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
package cc.fascinated.bat.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.token.thecatapi.CatImageToken;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.token.thecatapi.CatImageToken;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
package cc.fascinated.bat.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.token.dogceo.RandomImage;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.token.dogceo.RandomImage;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
package cc.fascinated.bat.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.token.randomd.RandomDuck;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.token.randomd.RandomDuck;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
package cc.fascinated.bat.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.token.randomfox.RandomFoxToken;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.token.randomfox.RandomFoxToken;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
package cc.fascinated.bat.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import cc.fascinated.bat.service.GuildService;
|
||||
import cc.fascinated.bat.service.UserService;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
package cc.fascinated.bat.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;
|
||||
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;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
package cc.fascinated.bat.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.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;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
package cc.fascinated.bat.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.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;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
package cc.fascinated.bat.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.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.server;
|
||||
package cc.fascinated.bat.base.commands.server;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.base.commands.server;
|
||||
package cc.fascinated.bat.base.commands.server;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.premium.PremiumProfile;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
package cc.fascinated.bat.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
package cc.fascinated.bat.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
package cc.fascinated.bat.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
package cc.fascinated.bat.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
package cc.fascinated.bat.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
package cc.fascinated.bat.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
package cc.fascinated.bat.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
package cc.fascinated.bat.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,13 +1,13 @@
|
||||
package cc.fascinated.bat.features.base.commands.utility;
|
||||
package cc.fascinated.bat.base.commands.utility;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.base.commands.utility.lookup;
|
||||
package cc.fascinated.bat.base.commands.utility.lookup;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.base.commands.utility.lookup;
|
||||
package cc.fascinated.bat.base.commands.utility.lookup;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.UserService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.birthday;
|
||||
package cc.fascinated.bat.birthday;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.birthday.command.BirthdayCommand;
|
||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
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.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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.features.birthday;
|
||||
package cc.fascinated.bat.birthday;
|
||||
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import com.google.gson.Gson;
|
@ -1,8 +1,8 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.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;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,11 +1,11 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.bat.features.birthday.command;
|
||||
package cc.fascinated.bat.birthday.command;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.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.features.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import cc.fascinated.bat.service.UserService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
@ -1,9 +1,9 @@
|
||||
package cc.fascinated.bat.features.birthday.profile;
|
||||
package cc.fascinated.bat.birthday.profile;
|
||||
|
||||
import cc.fascinated.bat.common.ChannelUtils;
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import cc.fascinated.bat.features.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.birthday.UserBirthday;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
@ -1,246 +1,140 @@
|
||||
package cc.fascinated.bat.command;
|
||||
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.*;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.IntegrationType;
|
||||
import net.dv8tion.jda.api.interactions.InteractionContextType;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
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.SubcommandData;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
|
||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Braydon
|
||||
*/
|
||||
@Getter
|
||||
public abstract class BatCommand {
|
||||
@Setter@Getter
|
||||
public abstract class BatCommand extends ListenerAdapter implements IBatCommand {
|
||||
/**
|
||||
* The info of this command.
|
||||
* The snowflake of this command, if it
|
||||
* was successfully registered on Discord.
|
||||
*/
|
||||
@NonNull
|
||||
private final InternalCommandInfo info;
|
||||
private Long snowflake;
|
||||
|
||||
/**
|
||||
* The feature this command belongs to.
|
||||
* The data for this command.
|
||||
*/
|
||||
@Setter
|
||||
private Feature feature;
|
||||
@NonNull private final SlashCommandData commandData;
|
||||
|
||||
/**
|
||||
* The snowflake of this command, set when
|
||||
* this command is registered with Discord.
|
||||
* The category of this command.
|
||||
*/
|
||||
@Setter
|
||||
private long snowflake;
|
||||
@NonNull private final CommandCategory category;
|
||||
|
||||
/**
|
||||
* The sub commands of this command, if any.
|
||||
* The sub-commands for this command.
|
||||
*/
|
||||
private final Map<String, BatCommand> subCommands = Collections.synchronizedMap(new HashMap<>());
|
||||
@NonNull private final List<BatSubCommand> subCommands = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
/**
|
||||
* The internal data for this command.
|
||||
*/
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
private CommandDataImpl commandData;
|
||||
public BatCommand(@NonNull String name, @NonNull String description, @NonNull CommandCategory category, @NonNull OptionData... options) {
|
||||
this(name, description, category, DefaultMemberPermissions.ENABLED, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal subcommand data for this command.
|
||||
*/
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
private SubcommandData subcommandData;
|
||||
|
||||
public BatCommand() {
|
||||
if (!getClass().isAnnotationPresent(CommandInfo.class)) {
|
||||
throw new IllegalStateException("Missing @CommandInfo annotation in " + getClass().getSimpleName());
|
||||
}
|
||||
info = new InternalCommandInfo(getClass().getAnnotation(CommandInfo.class));
|
||||
commandData = new CommandDataImpl(info.getName(), info.getDescription())
|
||||
// .setDefaultPermissions(DefaultMemberPermissions.enabledFor(info.getPermissions()))
|
||||
.setIntegrationTypes(info.isUserInstall() ?
|
||||
EnumSet.of(IntegrationType.USER_INSTALL) :
|
||||
EnumSet.of(IntegrationType.GUILD_INSTALL)
|
||||
).setContexts(info.isGuildOnly() ?
|
||||
EnumSet.of(InteractionContextType.GUILD) :
|
||||
EnumSet.of(InteractionContextType.GUILD, InteractionContextType.BOT_DM, InteractionContextType.PRIVATE_CHANNEL)
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when this command is executed.
|
||||
* Get the name of this command.
|
||||
*
|
||||
* @param guild the guild the command was executed in, if any
|
||||
* @param user the user who executed the command
|
||||
* @param channel the channel the command was executed in
|
||||
* @param member the member who executed the command, null if not a guild
|
||||
* @param commandMessage the message that invoked this command, if any
|
||||
* @param arguments the arguments of the command, if any
|
||||
* @param event the event that invoked this command, if any
|
||||
* @return the command name
|
||||
*/
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member,
|
||||
Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
||||
@Override @NonNull
|
||||
public String getName() {
|
||||
return commandData.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the given sub commands.
|
||||
* Get the full name of this command.
|
||||
*
|
||||
* @param commands the commands to register
|
||||
* @return the full name
|
||||
*/
|
||||
protected final void addSubCommands(@NonNull BatCommand... commands) {
|
||||
for (BatCommand command : commands) {
|
||||
// Copy info from the parent command
|
||||
if (command.getInfo().getCategory() != info.getCategory()) {
|
||||
command.getInfo().setCategory(info.getCategory());
|
||||
}
|
||||
if (command.getInfo().getPermissions().length == 0) {
|
||||
command.getInfo().setPermissions(info.getPermissions());
|
||||
}
|
||||
if (command.getInfo().isGuildOnly() != info.isGuildOnly()) {
|
||||
command.getInfo().setGuildOnly(info.isGuildOnly());
|
||||
}
|
||||
if (command.getInfo().isBotOwnerOnly() != info.isBotOwnerOnly()) {
|
||||
command.getInfo().setBotOwnerOnly(info.isBotOwnerOnly());
|
||||
}
|
||||
@Override @NonNull
|
||||
public String getFullName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
command.setSubcommandData(new SubcommandData(command.getInfo().getName(), command.getInfo().getDescription()));
|
||||
for (OptionData option : command.getCommandData().getOptions()) {
|
||||
command.getSubcommandData().addOptions(option);
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
commandData.addSubcommands(command.getSubcommandData());
|
||||
subCommands.put(command.getInfo().getName(), command);
|
||||
getCommandData().addSubcommandGroups(new SubcommandGroupData(
|
||||
subCommand.getGroupName(),
|
||||
"The " + subCommand.getGroupName() + " group for /" + getName() + " " + subCommand.getName()
|
||||
).addSubcommands(subCommand.getCommandData()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given options
|
||||
* to this command.
|
||||
* Get a sub-command by name.
|
||||
*
|
||||
* @param options the options to add
|
||||
* @param group the sub-command group, null if none
|
||||
* @param name the sub-command name
|
||||
* @return the sub-command, null if not found
|
||||
*/
|
||||
protected final void addOptions(OptionData... options) {
|
||||
commandData.addOptions(options);
|
||||
}
|
||||
public final BatSubCommand getSubCommand(String group, @NonNull String name) {
|
||||
for (BatSubCommand subCommand : subCommands) {
|
||||
String commandGroup = subCommand.getGroupName();
|
||||
|
||||
/**
|
||||
* Get the sub command by its class.
|
||||
*
|
||||
* @param clazz the class of the sub command
|
||||
* @return the sub command
|
||||
*/
|
||||
public BatCommand getSubCommand(Class<? extends BatCommand> clazz) {
|
||||
for (Map.Entry<String, BatCommand> entry : subCommands.entrySet()) {
|
||||
if (entry.getValue().getClass().equals(clazz)) {
|
||||
return entry.getValue();
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to the message or interaction with the given contents.
|
||||
*
|
||||
* @param message the message to reply to, null if interaction
|
||||
* @param interaction the interaction to reply to, null if message
|
||||
* @param contents the contents to reply with
|
||||
*/
|
||||
public void replyMessage(Message message, SlashCommandInteraction interaction, String contents) {
|
||||
if (message != null) {
|
||||
message.reply(contents).queue();
|
||||
} else {
|
||||
interaction.reply(contents).queue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to the message or interaction with the given embed.
|
||||
*
|
||||
* @param message the message to reply to, null if interaction
|
||||
* @param interaction the interaction to reply to, null if message
|
||||
* @param builder the embed builder to reply with
|
||||
*/
|
||||
public void replyEmbed(Message message, SlashCommandInteraction interaction, EmbedBuilder builder) {
|
||||
if (message != null) {
|
||||
message.replyEmbeds(builder.build()).queue();
|
||||
} else {
|
||||
interaction.replyEmbeds(builder.build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the argument from the command.
|
||||
*
|
||||
* @param option the option to get from the slash command
|
||||
* @param arguments the arguments of the invoked command
|
||||
* @param argumentIndex the index of the argument in the command
|
||||
* @param concatenateLeftover whether to concatenate the leftover arguments
|
||||
* @param event the event that invoked the command
|
||||
* @return the argument
|
||||
*/
|
||||
public Argument getArgument(String option, String[] arguments, int argumentIndex, boolean concatenateLeftover, SlashCommandInteraction event) {
|
||||
return new Argument(option, arguments, argumentIndex, concatenateLeftover, event);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Argument {
|
||||
/**
|
||||
* The option to get from the slash command.
|
||||
*/
|
||||
private final String option;
|
||||
|
||||
/**
|
||||
* The arguments of the invoked command.
|
||||
*/
|
||||
private final String[] arguments;
|
||||
|
||||
/**
|
||||
* The index of the argument in the command.
|
||||
*/
|
||||
private final int argumentIndex;
|
||||
|
||||
/**
|
||||
* Whether to concatenate the leftover arguments.
|
||||
*/
|
||||
private final boolean concatenateLeftover;
|
||||
|
||||
/**
|
||||
* The event that invoked the command.
|
||||
*/
|
||||
private final SlashCommandInteraction event;
|
||||
|
||||
/**
|
||||
* Get the argument from the command.
|
||||
*
|
||||
* @return the argument
|
||||
*/
|
||||
public String getAsString() {
|
||||
if (event != null) { // Get the option from the event
|
||||
OptionMapping option = event.getOption(this.option);
|
||||
if (option == null) {
|
||||
return null;
|
||||
}
|
||||
return option.getAsString();
|
||||
}
|
||||
if (arguments.length < argumentIndex) { // Check if the argument index is out of bounds
|
||||
return null;
|
||||
}
|
||||
if (concatenateLeftover) { // Concatenate the leftover arguments
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = argumentIndex; i < arguments.length; i++) {
|
||||
builder.append(arguments[i]).append(" ");
|
||||
}
|
||||
return builder.toString().trim();
|
||||
}
|
||||
return arguments[argumentIndex]; // Get the argument at the index
|
||||
}
|
||||
}
|
||||
}
|
82
src/main/java/cc/fascinated/bat/command/BatSubCommand.java
Normal file
82
src/main/java/cc/fascinated/bat/command/BatSubCommand.java
Normal 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());
|
||||
}
|
||||
}
|
25
src/main/java/cc/fascinated/bat/command/CommandCategory.java
Normal file
25
src/main/java/cc/fascinated/bat/command/CommandCategory.java
Normal 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);
|
||||
}
|
||||
}
|
97
src/main/java/cc/fascinated/bat/command/IBatCommand.java
Normal file
97
src/main/java/cc/fascinated/bat/command/IBatCommand.java
Normal 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());
|
||||
}
|
||||
}
|
@ -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 { }
|
@ -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 {}
|
186
src/main/java/cc/fascinated/bat/command/command/HelpCommand.java
Normal file
186
src/main/java/cc/fascinated/bat/command/command/HelpCommand.java
Normal 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();
|
||||
}
|
||||
}
|
44
src/main/java/cc/fascinated/bat/common/BatEmoji.java
Normal file
44
src/main/java/cc/fascinated/bat/common/BatEmoji.java
Normal 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 + ">";
|
||||
}
|
||||
}
|
@ -3,12 +3,18 @@ package cc.fascinated.bat.common;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@UtilityClass
|
||||
public class DateUtils {
|
||||
private static final ZoneId ZONE_ID = ZoneId.of("Europe/London");
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;
|
||||
private static final DateTimeFormatter SIMPLE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z")
|
||||
.withLocale(Locale.UK)
|
||||
.withZone(ZONE_ID);
|
||||
|
||||
/**
|
||||
* Gets the date from a string.
|
||||
@ -19,4 +25,14 @@ public class DateUtils {
|
||||
public static Date getDateFromString(String date) {
|
||||
return Date.from(Instant.from(FORMATTER.parse(date)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date to a string.
|
||||
*
|
||||
* @param date The date to format.
|
||||
* @return The formatted date.
|
||||
*/
|
||||
public String formatDate(Date date) {
|
||||
return SIMPLE_FORMATTER.format(date.toInstant());
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,14 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.InteractionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
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.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
|
||||
import net.dv8tion.jda.api.interactions.components.ItemComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
|
||||
import net.dv8tion.jda.api.interactions.components.selections.SelectOption;
|
||||
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
|
||||
import net.dv8tion.jda.api.utils.data.SerializableData;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -27,8 +16,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.dv8tion.jda.api.interactions.components.Component.Type.STRING_SELECT;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
|
294
src/main/java/cc/fascinated/bat/common/InteractionResponder.java
Normal file
294
src/main/java/cc/fascinated/bat/common/InteractionResponder.java
Normal 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;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
96
src/main/java/cc/fascinated/bat/common/MiscUtils.java
Normal file
96
src/main/java/cc/fascinated/bat/common/MiscUtils.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.BatApplication;
|
||||
import cc.fascinated.bat.model.token.paste.PasteUploadToken;
|
||||
import cc.fascinated.bat.common.model.token.paste.PasteUploadToken;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@ -18,7 +18,7 @@ import java.net.http.HttpResponse;
|
||||
@Log4j2(topic = "PasteUtils")
|
||||
public class PasteUtils {
|
||||
private static final String PASTE_URL = "https://paste.fascinated.cc/";
|
||||
private static final String PASTE_UPLOAD_URL = PASTE_URL + "api/upload";
|
||||
private static final String PASTE_UPLOAD_URL = PASTE_URL + "api/upload?expires=" + 60 * 60 * 24 * 30; // 30 days
|
||||
private static final HttpClient httpClient = HttpClient.newHttpClient();
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
@ -1,71 +0,0 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.SpotifyService;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying;
|
||||
import se.michaelthelin.spotify.model_objects.specification.Track;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@UtilityClass
|
||||
@Log4j2(topic = "Spotify Utils")
|
||||
public class SpotifyUtils {
|
||||
/**
|
||||
* Gets the URL of the track that is currently playing.
|
||||
*
|
||||
* @param currentlyPlaying The currently playing object.
|
||||
* @return The URL of the track that is currently playing.
|
||||
*/
|
||||
public static String getTrackUrl(CurrentlyPlaying currentlyPlaying) {
|
||||
return "https://open.spotify.com/track/" + currentlyPlaying.getItem().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the formatted time of the currently playing track
|
||||
*
|
||||
* @param currentlyPlaying the currently playing track
|
||||
* @return the formatted time
|
||||
*/
|
||||
public static String getFormattedTime(@NonNull CurrentlyPlaying currentlyPlaying) {
|
||||
Track track = (Track) currentlyPlaying.getItem();
|
||||
int currentMinutes = currentlyPlaying.getProgress_ms() / 1000 / 60;
|
||||
int currentSeconds = currentlyPlaying.getProgress_ms() / 1000 % 60;
|
||||
int totalMinutes = track.getDurationMs() / 1000 / 60;
|
||||
int totalSeconds = track.getDurationMs() / 1000 % 60;
|
||||
|
||||
return "`%02d:%02d`/`%02d:%02d`".formatted(currentMinutes, currentSeconds, totalMinutes, totalSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next track that is playing
|
||||
*
|
||||
* @param user The user to get the track for
|
||||
* @param oldName The name of the old track
|
||||
* @return The new track
|
||||
*/
|
||||
public static CurrentlyPlaying getNewTrack(@NonNull SpotifyService spotifyService, @NonNull BatUser user, @NonNull String oldName) {
|
||||
int checks = 0;
|
||||
|
||||
try {
|
||||
Thread.sleep(150);
|
||||
while (checks < 10) {
|
||||
CurrentlyPlaying currentlyPlaying = spotifyService.getCurrentlyPlayingTrack(user);
|
||||
Track track = (Track) currentlyPlaying.getItem();
|
||||
if (track.getName().equals(oldName)) {
|
||||
Thread.sleep(250);
|
||||
checks++;
|
||||
} else {
|
||||
log.info("Found new track \"{}\" in {} check{}", track.getName(), checks, checks == 1 ? "" : "s");
|
||||
return currentlyPlaying;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package cc.fascinated.bat.common.beatsaber.leaderboard;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
public class Leaderboard {
|
||||
/**
|
||||
* The name of the leaderboard.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The version of the leaderboard.
|
||||
*/
|
||||
private int curveVersion;
|
||||
|
||||
/**
|
||||
* The curve of the leaderboard.
|
||||
*/
|
||||
private final LeaderboardCurvePoint[] curve;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package cc.fascinated.bat.common.beatsaber.leaderboard;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter @AllArgsConstructor
|
||||
public class LeaderboardCurvePoint {
|
||||
private final double a;
|
||||
private final double b;
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
package cc.fascinated.bat.common.beatsaber.leaderboard.impl;
|
||||
|
||||
import cc.fascinated.bat.common.MathUtils;
|
||||
import cc.fascinated.bat.common.beatsaber.leaderboard.Leaderboard;
|
||||
import cc.fascinated.bat.common.beatsaber.leaderboard.LeaderboardCurvePoint;
|
||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberScoreToken;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Log4j2(topic = "ScoreSaber Leaderboard")
|
||||
public class ScoreSaberLeaderboard extends Leaderboard {
|
||||
public static final ScoreSaberLeaderboard INSTANCE = new ScoreSaberLeaderboard();
|
||||
|
||||
/**
|
||||
* The base multiplier for stars.
|
||||
*/
|
||||
private final double starMultiplier = 42.11;
|
||||
|
||||
/**
|
||||
* no idea, ngl
|
||||
*/
|
||||
private final double weightCoefficient = 0.965;
|
||||
|
||||
public ScoreSaberLeaderboard() {
|
||||
super("ScoreSaber", 1, new LeaderboardCurvePoint[] {
|
||||
new LeaderboardCurvePoint(1.0, 5.367394282890631),
|
||||
new LeaderboardCurvePoint(0.9995, 5.019543595874787),
|
||||
new LeaderboardCurvePoint(0.999, 4.715470646416203),
|
||||
new LeaderboardCurvePoint(0.99825, 4.325027383589547),
|
||||
new LeaderboardCurvePoint(0.9975, 3.996793606763322),
|
||||
new LeaderboardCurvePoint(0.99625, 3.5526145337555373),
|
||||
new LeaderboardCurvePoint(0.995, 3.2022017597337955),
|
||||
new LeaderboardCurvePoint(0.99375, 2.9190155639254955),
|
||||
new LeaderboardCurvePoint(0.9925, 2.685667856592722),
|
||||
new LeaderboardCurvePoint(0.99125, 2.4902905794106913),
|
||||
new LeaderboardCurvePoint(0.99, 2.324506282149922),
|
||||
new LeaderboardCurvePoint(0.9875, 2.058947159052738),
|
||||
new LeaderboardCurvePoint(0.985, 1.8563887693647105),
|
||||
new LeaderboardCurvePoint(0.9825, 1.697536248647543),
|
||||
new LeaderboardCurvePoint(0.98, 1.5702410055532239),
|
||||
new LeaderboardCurvePoint(0.9775, 1.4664726399289512),
|
||||
new LeaderboardCurvePoint(0.975, 1.3807102743105126),
|
||||
new LeaderboardCurvePoint(0.9725, 1.3090333065057616),
|
||||
new LeaderboardCurvePoint(0.97, 1.2485807759957321),
|
||||
new LeaderboardCurvePoint(0.965, 1.1552120359501035),
|
||||
new LeaderboardCurvePoint(0.96, 1.0871883573850478),
|
||||
new LeaderboardCurvePoint(0.955, 1.0388633331418984),
|
||||
new LeaderboardCurvePoint(0.95, 1.0),
|
||||
new LeaderboardCurvePoint(0.94, 0.9417362980580238),
|
||||
new LeaderboardCurvePoint(0.93, 0.9039994071865736),
|
||||
new LeaderboardCurvePoint(0.92, 0.8728710341448851),
|
||||
new LeaderboardCurvePoint(0.91, 0.8488375988124467),
|
||||
new LeaderboardCurvePoint(0.9, 0.825756123560842),
|
||||
new LeaderboardCurvePoint(0.875, 0.7816934560296046),
|
||||
new LeaderboardCurvePoint(0.85, 0.7462290664143185),
|
||||
new LeaderboardCurvePoint(0.825, 0.7150465663454271),
|
||||
new LeaderboardCurvePoint(0.8, 0.6872268862950283),
|
||||
new LeaderboardCurvePoint(0.75, 0.6451808210101443),
|
||||
new LeaderboardCurvePoint(0.7, 0.6125565959114954),
|
||||
new LeaderboardCurvePoint(0.65, 0.5866010012767576),
|
||||
new LeaderboardCurvePoint(0.6, 0.18223233667439062),
|
||||
new LeaderboardCurvePoint(0.0, 0.0)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the modifier for the given accuracy.
|
||||
*
|
||||
* @param accuracy The accuracy.
|
||||
* @return The modifier.
|
||||
*/
|
||||
public double getModifier(double accuracy) {
|
||||
accuracy = MathUtils.clamp(accuracy, 0, 100) / 100;
|
||||
|
||||
LeaderboardCurvePoint prev = this.getCurve()[1];
|
||||
for (LeaderboardCurvePoint point : this.getCurve()) {
|
||||
if (point.getA() <= accuracy) {
|
||||
double distance = (prev.getA() - accuracy) / (prev.getA() - point.getA());
|
||||
return MathUtils.lerp(prev.getB(), point.getB(), distance);
|
||||
}
|
||||
prev = point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pp for the given accuracy and stars.
|
||||
*
|
||||
* @param accuracy The accuracy.
|
||||
* @param stars The stars.
|
||||
* @return The pp.
|
||||
*/
|
||||
public double getPP(double accuracy, double stars) {
|
||||
double pp = stars * this.starMultiplier;
|
||||
double modifier = this.getModifier(accuracy);
|
||||
return modifier * pp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total pp for the given scores.
|
||||
*
|
||||
* @param scores The scores.
|
||||
* @return The total pp.
|
||||
*/
|
||||
private double getTotalPP(List<ScoreSaberScoreToken> scores, int startIdx) {
|
||||
double totalPP = 0;
|
||||
for (int i = 0; i < scores.size(); i++) {
|
||||
totalPP += Math.pow(this.weightCoefficient, i + startIdx) * scores.get(i).getPp();
|
||||
}
|
||||
return totalPP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pp at the given index for the given scores.
|
||||
*
|
||||
* @param bottomScores The scores.
|
||||
* @param idx The index.
|
||||
* @return The pp.
|
||||
*/
|
||||
private double getRawPPAtIdx(List<ScoreSaberScoreToken> bottomScores, int idx, double expected) {
|
||||
double oldBottomPP = this.getTotalPP(bottomScores, idx);
|
||||
double newBottomPP = this.getTotalPP(bottomScores, idx + 1);
|
||||
|
||||
return (expected + oldBottomPP - newBottomPP) / Math.pow(this.weightCoefficient, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw pp per global pp for the given scores.
|
||||
*
|
||||
* @param scores The scores.
|
||||
* @param expectedPP The expected pp.
|
||||
* @return The raw pp per global pp.
|
||||
*/
|
||||
public double getRawPerGlobalPP(List<ScoreSaberScoreToken> scores, double expectedPP) {
|
||||
int left = 0;
|
||||
int right = scores.size() - 1;
|
||||
int boundaryIdx = -1;
|
||||
|
||||
// Sort by PP
|
||||
scores.sort((a, b) -> Double.compare(b.getPp(), a.getPp()));
|
||||
|
||||
while (left <= right) {
|
||||
int mid = (left + right) / 2;
|
||||
double bottomPP = this.getTotalPP(scores.subList(mid, scores.size()), mid);
|
||||
|
||||
List<ScoreSaberScoreToken> bottomSlice = new ArrayList<>(scores.subList(mid, scores.size()));
|
||||
bottomSlice.add(0, scores.get(mid));
|
||||
double modifiedBottomPP = this.getTotalPP(bottomSlice, mid);
|
||||
double diff = modifiedBottomPP - bottomPP;
|
||||
|
||||
if (diff > expectedPP) {
|
||||
boundaryIdx = mid;
|
||||
left = mid + 1;
|
||||
} else {
|
||||
right = mid - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (boundaryIdx == -1) {
|
||||
return this.getRawPPAtIdx(scores, 0, expectedPP);
|
||||
} else {
|
||||
return this.getRawPPAtIdx(scores.subList(boundaryIdx + 1, scores.size()), boundaryIdx + 1, expectedPP);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.features;
|
||||
package cc.fascinated.bat.common.feature;
|
||||
|
||||
import cc.fascinated.bat.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);
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.features;
|
||||
package cc.fascinated.bat.common.feature;
|
||||
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import com.google.gson.Gson;
|
@ -1,19 +1,18 @@
|
||||
package cc.fascinated.bat.model;
|
||||
package cc.fascinated.bat.common.model;
|
||||
|
||||
import cc.fascinated.bat.BatApplication;
|
||||
import cc.fascinated.bat.common.ProfileHolder;
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.features.counter.CounterProfile;
|
||||
import cc.fascinated.bat.features.leveling.LevelingProfile;
|
||||
import cc.fascinated.bat.features.logging.LogProfile;
|
||||
import cc.fascinated.bat.features.minecraft.MinecraftProfile;
|
||||
import cc.fascinated.bat.features.moderation.punish.PunishmentProfile;
|
||||
import cc.fascinated.bat.features.namehistory.profile.guild.NameHistoryProfile;
|
||||
import cc.fascinated.bat.features.reminder.ReminderProfile;
|
||||
import cc.fascinated.bat.features.statschannel.StatsChannelProfile;
|
||||
import cc.fascinated.bat.features.welcomer.WelcomerProfile;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.counter.CounterProfile;
|
||||
import cc.fascinated.bat.leveling.LevelingProfile;
|
||||
import cc.fascinated.bat.logging.LogProfile;
|
||||
import cc.fascinated.bat.moderation.punish.PunishmentProfile;
|
||||
import cc.fascinated.bat.namehistory.profile.guild.NameHistoryProfile;
|
||||
import cc.fascinated.bat.reminder.ReminderProfile;
|
||||
import cc.fascinated.bat.statschannel.StatsChannelProfile;
|
||||
import cc.fascinated.bat.welcomer.WelcomerProfile;
|
||||
import cc.fascinated.bat.premium.PremiumProfile;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import cc.fascinated.bat.service.MongoService;
|
||||
@ -23,8 +22,6 @@ import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
@ -182,15 +179,6 @@ public class BatGuild extends ProfileHolder {
|
||||
return getProfile(LevelingProfile.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minecraft profile
|
||||
*
|
||||
* @return the minecraft profile
|
||||
*/
|
||||
public MinecraftProfile getMinecraftProfile() {
|
||||
return getProfile(MinecraftProfile.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stats channel profile
|
||||
*
|
@ -1,11 +1,10 @@
|
||||
package cc.fascinated.bat.model;
|
||||
package cc.fascinated.bat.common.model;
|
||||
|
||||
import cc.fascinated.bat.BatApplication;
|
||||
import cc.fascinated.bat.common.ProfileHolder;
|
||||
import cc.fascinated.bat.common.Serializable;
|
||||
import cc.fascinated.bat.common.UserUtils;
|
||||
import cc.fascinated.bat.features.namehistory.profile.user.NameHistoryProfile;
|
||||
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||
import cc.fascinated.bat.namehistory.profile.user.NameHistoryProfile;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import cc.fascinated.bat.service.MongoService;
|
||||
import com.mongodb.client.model.ReplaceOptions;
|
||||
@ -87,15 +86,6 @@ public class BatUser extends ProfileHolder {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user's ScoreSaber profile
|
||||
*
|
||||
* @return the user's ScoreSaber profile
|
||||
*/
|
||||
public ScoreSaberProfile getScoreSaberProfile() {
|
||||
return getProfile(ScoreSaberProfile.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user's name history profile
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model;
|
||||
package cc.fascinated.bat.common.model;
|
||||
|
||||
import cc.fascinated.bat.common.ChannelUtils;
|
||||
import cc.fascinated.bat.common.UserUtils;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.beatsaber.scoresaber;
|
||||
package cc.fascinated.bat.common.model.token.beatsaber.scoresaber;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.dogceo;
|
||||
package cc.fascinated.bat.common.model.token.dogceo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.paste;
|
||||
package cc.fascinated.bat.common.model.token.paste;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.randomd;
|
||||
package cc.fascinated.bat.common.model.token.randomd;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.randomfox;
|
||||
package cc.fascinated.bat.common.model.token.randomfox;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.model.token.thecatapi;
|
||||
package cc.fascinated.bat.common.model.token.thecatapi;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -0,0 +1,248 @@
|
||||
package cc.fascinated.bat.common.oldcommand;
|
||||
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.*;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.IntegrationType;
|
||||
import net.dv8tion.jda.api.interactions.InteractionContextType;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Braydon
|
||||
*/
|
||||
@Getter
|
||||
public abstract class BatCommand {
|
||||
/**
|
||||
* The info of this command.
|
||||
*/
|
||||
@NonNull
|
||||
private final InternalCommandInfo info;
|
||||
|
||||
/**
|
||||
* The feature this command belongs to.
|
||||
*/
|
||||
@Setter
|
||||
private Feature feature;
|
||||
|
||||
/**
|
||||
* The snowflake of this command, set when
|
||||
* this command is registered with Discord.
|
||||
*/
|
||||
@Setter
|
||||
private long snowflake;
|
||||
|
||||
/**
|
||||
* The sub commands of this command, if any.
|
||||
*/
|
||||
private final Map<String, BatCommand> subCommands = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
/**
|
||||
* The internal data for this command.
|
||||
*/
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
private CommandDataImpl commandData;
|
||||
|
||||
/**
|
||||
* The internal subcommand data for this command.
|
||||
*/
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
private SubcommandData subcommandData;
|
||||
|
||||
public BatCommand() {
|
||||
if (!getClass().isAnnotationPresent(CommandInfo.class)) {
|
||||
throw new IllegalStateException("Missing @CommandInfo annotation in " + getClass().getSimpleName());
|
||||
}
|
||||
info = new InternalCommandInfo(getClass().getAnnotation(CommandInfo.class));
|
||||
commandData = new CommandDataImpl(info.getName(), info.getDescription())
|
||||
// .setDefaultPermissions(DefaultMemberPermissions.enabledFor(info.getPermissions()))
|
||||
.setIntegrationTypes(info.isUserInstall() ?
|
||||
EnumSet.of(IntegrationType.USER_INSTALL) :
|
||||
EnumSet.of(IntegrationType.GUILD_INSTALL)
|
||||
).setContexts(info.isGuildOnly() ?
|
||||
EnumSet.of(InteractionContextType.GUILD) :
|
||||
EnumSet.of(InteractionContextType.GUILD, InteractionContextType.BOT_DM, InteractionContextType.PRIVATE_CHANNEL)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when this command is executed.
|
||||
*
|
||||
* @param guild the guild the command was executed in, if any
|
||||
* @param user the user who executed the command
|
||||
* @param channel the channel the command was executed in
|
||||
* @param member the member who executed the command, null if not a guild
|
||||
* @param commandMessage the message that invoked this command, if any
|
||||
* @param arguments the arguments of the command, if any
|
||||
* @param event the event that invoked this command, if any
|
||||
*/
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member,
|
||||
Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the given sub commands.
|
||||
*
|
||||
* @param commands the commands to register
|
||||
*/
|
||||
protected final void addSubCommands(@NonNull BatCommand... commands) {
|
||||
for (BatCommand command : commands) {
|
||||
// Copy info from the parent command
|
||||
if (command.getInfo().getCategory() != info.getCategory()) {
|
||||
command.getInfo().setCategory(info.getCategory());
|
||||
}
|
||||
if (command.getInfo().getPermissions().length == 0) {
|
||||
command.getInfo().setPermissions(info.getPermissions());
|
||||
}
|
||||
if (command.getInfo().isGuildOnly() != info.isGuildOnly()) {
|
||||
command.getInfo().setGuildOnly(info.isGuildOnly());
|
||||
}
|
||||
if (command.getInfo().isBotOwnerOnly() != info.isBotOwnerOnly()) {
|
||||
command.getInfo().setBotOwnerOnly(info.isBotOwnerOnly());
|
||||
}
|
||||
|
||||
command.setSubcommandData(new SubcommandData(command.getInfo().getName(), command.getInfo().getDescription()));
|
||||
for (OptionData option : command.getCommandData().getOptions()) {
|
||||
command.getSubcommandData().addOptions(option);
|
||||
}
|
||||
commandData.addSubcommands(command.getSubcommandData());
|
||||
subCommands.put(command.getInfo().getName(), command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given options
|
||||
* to this command.
|
||||
*
|
||||
* @param options the options to add
|
||||
*/
|
||||
protected final void addOptions(OptionData... options) {
|
||||
commandData.addOptions(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sub command by its class.
|
||||
*
|
||||
* @param clazz the class of the sub command
|
||||
* @return the sub command
|
||||
*/
|
||||
public BatCommand getSubCommand(Class<? extends BatCommand> clazz) {
|
||||
for (Map.Entry<String, BatCommand> entry : subCommands.entrySet()) {
|
||||
if (entry.getValue().getClass().equals(clazz)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to the message or interaction with the given contents.
|
||||
*
|
||||
* @param message the message to reply to, null if interaction
|
||||
* @param interaction the interaction to reply to, null if message
|
||||
* @param contents the contents to reply with
|
||||
*/
|
||||
public void replyMessage(Message message, SlashCommandInteraction interaction, String contents) {
|
||||
if (message != null) {
|
||||
message.reply(contents).queue();
|
||||
} else {
|
||||
interaction.reply(contents).queue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to the message or interaction with the given embed.
|
||||
*
|
||||
* @param message the message to reply to, null if interaction
|
||||
* @param interaction the interaction to reply to, null if message
|
||||
* @param builder the embed builder to reply with
|
||||
*/
|
||||
public void replyEmbed(Message message, SlashCommandInteraction interaction, EmbedBuilder builder) {
|
||||
if (message != null) {
|
||||
message.replyEmbeds(builder.build()).queue();
|
||||
} else {
|
||||
interaction.replyEmbeds(builder.build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the argument from the command.
|
||||
*
|
||||
* @param option the option to get from the slash command
|
||||
* @param arguments the arguments of the invoked command
|
||||
* @param argumentIndex the index of the argument in the command
|
||||
* @param concatenateLeftover whether to concatenate the leftover arguments
|
||||
* @param event the event that invoked the command
|
||||
* @return the argument
|
||||
*/
|
||||
public Argument getArgument(String option, String[] arguments, int argumentIndex, boolean concatenateLeftover, SlashCommandInteraction event) {
|
||||
return new Argument(option, arguments, argumentIndex, concatenateLeftover, event);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Argument {
|
||||
/**
|
||||
* The option to get from the slash command.
|
||||
*/
|
||||
private final String option;
|
||||
|
||||
/**
|
||||
* The arguments of the invoked command.
|
||||
*/
|
||||
private final String[] arguments;
|
||||
|
||||
/**
|
||||
* The index of the argument in the command.
|
||||
*/
|
||||
private final int argumentIndex;
|
||||
|
||||
/**
|
||||
* Whether to concatenate the leftover arguments.
|
||||
*/
|
||||
private final boolean concatenateLeftover;
|
||||
|
||||
/**
|
||||
* The event that invoked the command.
|
||||
*/
|
||||
private final SlashCommandInteraction event;
|
||||
|
||||
/**
|
||||
* Get the argument from the command.
|
||||
*
|
||||
* @return the argument
|
||||
*/
|
||||
public String getAsString() {
|
||||
if (event != null) { // Get the option from the event
|
||||
OptionMapping option = event.getOption(this.option);
|
||||
if (option == null) {
|
||||
return null;
|
||||
}
|
||||
return option.getAsString();
|
||||
}
|
||||
if (arguments.length < argumentIndex) { // Check if the argument index is out of bounds
|
||||
return null;
|
||||
}
|
||||
if (concatenateLeftover) { // Concatenate the leftover arguments
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = argumentIndex; i < arguments.length; i++) {
|
||||
builder.append(arguments[i]).append(" ");
|
||||
}
|
||||
return builder.toString().trim();
|
||||
}
|
||||
return arguments[argumentIndex]; // Get the argument at the index
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command;
|
||||
package cc.fascinated.bat.common.oldcommand;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user