All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 36s
47 lines
1.9 KiB
Java
47 lines
1.9 KiB
Java
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 cc.fascinated.bat.service.GuildService;
|
|
import cc.fascinated.bat.service.UserService;
|
|
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.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* @author Fascinated (fascinated7)
|
|
*/
|
|
@Component
|
|
public class BotStatsCommand extends BatCommand {
|
|
private final GuildService guildService;
|
|
private final UserService userService;
|
|
|
|
@Autowired
|
|
public BotStatsCommand(@NonNull GuildService guildService, @NonNull UserService userService) {
|
|
super("botstats", "Shows the bot statistics");
|
|
this.guildService = guildService;
|
|
this.userService = userService;
|
|
}
|
|
|
|
@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(
|
|
"**Bot Statistics**\n" +
|
|
"➜ Guilds: %s\n".formatted(jda.getGuilds().size()) +
|
|
"➜ Users: %s\n".formatted(jda.getUsers().size()) +
|
|
"➜ Gateway Ping: %sms\n".formatted(jda.getGatewayPing()) +
|
|
"➜ Cached Guilds: %s\n".formatted(guildService.getGuilds().size()) +
|
|
"➜ Cached Users: %s".formatted(userService.getUsers().size())
|
|
).build()).queue();
|
|
}
|
|
}
|