From 99570d6f86a4f211a5237687bc5233851ad2967b Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 27 Jun 2024 11:28:38 +0100 Subject: [PATCH] add botstats command --- .../bat/command/impl/BotStatsCommand.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/cc/fascinated/bat/command/impl/BotStatsCommand.java diff --git a/src/main/java/cc/fascinated/bat/command/impl/BotStatsCommand.java b/src/main/java/cc/fascinated/bat/command/impl/BotStatsCommand.java new file mode 100644 index 0000000..9bf3b0c --- /dev/null +++ b/src/main/java/cc/fascinated/bat/command/impl/BotStatsCommand.java @@ -0,0 +1,34 @@ +package cc.fascinated.bat.command.impl; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.model.BatGuild; +import cc.fascinated.bat.model.BatUser; +import cc.fascinated.bat.service.DiscordService; +import lombok.NonNull; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; +import org.springframework.stereotype.Component; + +/** + * @author Fascinated (fascinated7) + */ +@Component +public class BotStatsCommand extends BatCommand { + public BotStatsCommand() { + super("botstats", "Shows the bot statistics"); + } + + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { + JDA jda = DiscordService.JDA; + interaction.replyEmbeds(EmbedUtils.genericEmbed() + .setDescription("An overview of the bot statistics") + .addField("Guilds", jda.getGuilds().size() + "", true) + .addField("Users", jda.getUsers().size() + "", true) + .addField("Gateway Ping", jda.getGatewayPing() + "ms", true) + .build()).queue(); + } +}