forked from Fascinated/Bat
Merge branch 'master' into master
This commit is contained in:
@ -15,7 +15,8 @@ import java.util.Map;
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class BatCommand implements BatCommandExecutor {
|
||||
/**
|
||||
* The information about the command
|
||||
@ -69,10 +70,10 @@ public abstract class BatCommand implements BatCommandExecutor {
|
||||
/**
|
||||
* Adds an option to the sub command
|
||||
*
|
||||
* @param optionType the type of the option
|
||||
* @param name the name of the option
|
||||
* @param optionType the type of the option
|
||||
* @param name the name of the option
|
||||
* @param description the description of the option
|
||||
* @param required whether the option is required
|
||||
* @param required whether the option is required
|
||||
*/
|
||||
protected void addOption(OptionType optionType, String name, String description, boolean required) {
|
||||
this.commandData.addOption(optionType, name, description, required);
|
||||
|
@ -14,10 +14,10 @@ public interface BatCommandExecutor {
|
||||
/**
|
||||
* Executes the command using a slash command interaction.
|
||||
*
|
||||
* @param guild the bat guild the command was executed in (null if the command was executed in a DM)
|
||||
* @param user the bat user that executed the command
|
||||
* @param channel the channel the command was executed in
|
||||
* @param member the member that executed the command
|
||||
* @param guild the bat guild the command was executed in (null if the command was executed in a DM)
|
||||
* @param user the bat user that executed the command
|
||||
* @param channel the channel the command was executed in
|
||||
* @param member the member that executed the command
|
||||
* @param interaction the slash command interaction
|
||||
*/
|
||||
default void execute(
|
||||
@ -26,5 +26,6 @@ public interface BatCommandExecutor {
|
||||
@NonNull MessageChannel channel,
|
||||
Member member,
|
||||
@NonNull SlashCommandInteraction interaction
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
@Setter
|
||||
public class BatSubCommand implements BatCommandExecutor {
|
||||
/**
|
||||
* The information about the sub command
|
||||
@ -33,10 +34,10 @@ public class BatSubCommand implements BatCommandExecutor {
|
||||
/**
|
||||
* Adds an option to the sub command
|
||||
*
|
||||
* @param optionType the type of the option
|
||||
* @param name the name of the option
|
||||
* @param optionType the type of the option
|
||||
* @param name the name of the option
|
||||
* @param description the description of the option
|
||||
* @param required whether the option is required
|
||||
* @param required whether the option is required
|
||||
*/
|
||||
public void addOption(OptionType optionType, String name, String description, boolean required) {
|
||||
this.commandData.addOption(optionType, name, description, required);
|
||||
|
@ -10,12 +10,14 @@ import java.util.List;
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Category {
|
||||
GENERAL(Emoji.fromUnicode("U+2699"), "General", false),
|
||||
FUN(Emoji.fromFormatted("U+1F973"), "Fun", false),
|
||||
SERVER(Emoji.fromFormatted("U+1F5A5"), "Server", false),
|
||||
UTILITY(Emoji.fromFormatted("U+1F6E0"), "Utility", false),
|
||||
MUSIC(Emoji.fromFormatted("U+1F3B5"), "Music", false),
|
||||
BEAT_SABER(Emoji.fromFormatted("U+1FA84"), "Beat Saber", false),
|
||||
BOT_ADMIN(null, null, true);
|
||||
|
||||
|
@ -26,9 +26,9 @@ import java.lang.management.RuntimeMXBean;
|
||||
@Component
|
||||
@CommandInfo(name = "botstats", description = "Shows the bot statistics", guildOnly = false)
|
||||
public class BotStatsCommand extends BatCommand {
|
||||
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
|
||||
private final GuildService guildService;
|
||||
private final UserService userService;
|
||||
private final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
|
||||
|
||||
@Autowired
|
||||
public BotStatsCommand(@NonNull GuildService guildService, @NonNull UserService userService) {
|
||||
@ -42,14 +42,14 @@ public class BotStatsCommand extends BatCommand {
|
||||
|
||||
interaction.replyEmbeds(EmbedUtils.genericEmbed().setDescription(
|
||||
"**Bot Statistics**\n" +
|
||||
"➜ Guilds: %s\n".formatted(jda.getGuilds().size()) +
|
||||
"➜ Users: %s\n".formatted(jda.getUsers().size()) +
|
||||
"➜ Gateway Ping: %sms\n".formatted(jda.getGatewayPing()) +
|
||||
"\n" +
|
||||
"**Bat Statistics**\n" +
|
||||
"➜ Uptime: %s\n".formatted(TimeUtils.format(bean.getUptime())) +
|
||||
"➜ Cached Guilds: %s\n".formatted(guildService.getGuilds().size()) +
|
||||
"➜ Cached Users: %s".formatted(userService.getUsers().size())
|
||||
"➜ Guilds: **%s\n".formatted(jda.getGuilds().size()) +
|
||||
"➜ Users: **%s\n".formatted(jda.getUsers().size()) +
|
||||
"➜ Gateway Ping: **%sms**\n".formatted(jda.getGatewayPing()) +
|
||||
"\n" +
|
||||
"**Bat Statistics**\n" +
|
||||
"➜ Uptime: **%s**\n".formatted(TimeUtils.format(bean.getUptime())) +
|
||||
"➜ Cached Guilds: **%s**\n".formatted(guildService.getGuilds().size()) +
|
||||
"➜ Cached Users: **%s**".formatted(userService.getUsers().size())
|
||||
).build()).queue();
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class HelpCommand extends BatCommand implements EventListener {
|
||||
SelectOption.of(category.getName(), category.getName()).withEmoji(category.getEmoji()))
|
||||
.toList());
|
||||
|
||||
return new LayoutComponent[] {
|
||||
return new LayoutComponent[]{
|
||||
ActionRow.of(
|
||||
Button.of(ButtonStyle.LINK, Consts.INVITE_URL, "Invite"),
|
||||
Button.of(ButtonStyle.LINK, Consts.SUPPORT_INVITE_URL, "Support")
|
||||
@ -147,4 +147,4 @@ public class HelpCommand extends BatCommand implements EventListener {
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class PingCommand extends BatCommand {
|
||||
interaction.reply("Pinging...").queue(response -> {
|
||||
response.editOriginal("Gateway response time: `%sms`\nAPI response time `%sms`".formatted(
|
||||
DiscordService.JDA.getGatewayPing(),
|
||||
System.currentTimeMillis() - time
|
||||
System.currentTimeMillis() - time
|
||||
)).queue();
|
||||
});
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class SetSubCommand extends BatSubCommand {
|
||||
}
|
||||
guildService.saveGuild(batGuild);
|
||||
if (!infinite) {
|
||||
interaction.reply("The guild **%s** has been set as premium until <t:%s>".formatted(guild.getName(), premium.getExpiresAt().toInstant().toEpochMilli()/1000)).queue();
|
||||
interaction.reply("The guild **%s** has been set as premium until <t:%s>".formatted(guild.getName(), premium.getExpiresAt().toInstant().toEpochMilli() / 1000)).queue();
|
||||
} else {
|
||||
interaction.reply("The guild **%s** has been set as premium indefinitely".formatted(guild.getName())).queue();
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ public class PremiumCommand extends BatCommand {
|
||||
EmbedBuilder embed = EmbedUtils.genericEmbed().setAuthor("Premium Information");
|
||||
if (premium.hasPremium()) {
|
||||
embed.addField("Premium", premium.hasPremium() ? "Yes" : "No", true);
|
||||
embed.addField("Started On", "<t:%d>".formatted(premium.getActivatedAt().toInstant().toEpochMilli()/1000), true);
|
||||
embed.addField("Expires At", premium.isInfinite() ? "Never" : "<t:%d>"
|
||||
.formatted(premium.getExpiresAt().toInstant().toEpochMilli()/1000), true);
|
||||
embed.addField("Started", "<t:%d>".formatted(premium.getActivatedAt().toInstant().toEpochMilli() / 1000), true);
|
||||
embed.addField("Expires", premium.isInfinite() ? "Never" : "<t:%d>"
|
||||
.formatted(premium.getExpiresAt().toInstant().toEpochMilli() / 1000), true);
|
||||
} else {
|
||||
embed.setDescription("The guild does not have premium");
|
||||
}
|
||||
|
Reference in New Issue
Block a user