From 306edf7017dcabe3c40954daa6b65454e790bec9 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 27 Jun 2024 19:25:33 -0500 Subject: [PATCH] Add MemberCountCommand --- .../impl/server/MemberCountCommand.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java diff --git a/src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java b/src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java new file mode 100644 index 0000000..43f9d4e --- /dev/null +++ b/src/main/java/cc/fascinated/bat/command/impl/server/MemberCountCommand.java @@ -0,0 +1,29 @@ +package cc.fascinated.bat.command.impl.server; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.command.CommandInfo; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.model.BatGuild; +import cc.fascinated.bat.model.BatUser; +import lombok.NonNull; +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.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; +import org.springframework.stereotype.Component; + +/** + * @author Nick (okNick) + */ +@Component +@CommandInfo(name = "membercount", description = "View the member count of the server!") +public class MemberCountCommand extends BatCommand { + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { + EmbedBuilder embed = EmbedUtils.genericEmbed().setAuthor("Member Count"); + Guild discordGuild = guild.getDiscordGuild(); + embed.setDescription(discordGuild.getName() + " has a total of " + discordGuild.getMembers().size() + " members."); + interaction.replyEmbeds(embed.build()).queue(); + } +} \ No newline at end of file