From bc68fe6c4157d16cb0545321f66518f798dd70f9 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 17 Mar 2021 17:52:21 +0100 Subject: [PATCH] Added MemberCountCommand --- .../badSportSystem/command/MuteCommand.java | 19 +++++++++ .../zone/themcgamer/discordbot/MGZBot.java | 2 + .../command/impl/MemberCountCommand.java | 39 +++++++++++++++++++ .../discordbot/events/GuildsListener.java | 2 +- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/zone/themcgamer/core/badSportSystem/command/MuteCommand.java create mode 100644 discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MemberCountCommand.java diff --git a/core/src/main/java/zone/themcgamer/core/badSportSystem/command/MuteCommand.java b/core/src/main/java/zone/themcgamer/core/badSportSystem/command/MuteCommand.java new file mode 100644 index 0000000..37774b4 --- /dev/null +++ b/core/src/main/java/zone/themcgamer/core/badSportSystem/command/MuteCommand.java @@ -0,0 +1,19 @@ +package zone.themcgamer.core.badSportSystem.command; + +import lombok.AllArgsConstructor; +import org.bukkit.entity.Player; +import zone.themcgamer.core.account.AccountManager; + +import zone.themcgamer.core.command.Command; +import zone.themcgamer.core.command.CommandProvider; +import zone.themcgamer.data.Rank; + +@AllArgsConstructor +public class MuteCommand { + private final AccountManager accountManager; + + @Command(name = "mute", aliases = { "bssmute" }, description = "Mute a player", ranks = { Rank.HELPER }, playersOnly = true) + public void onCommand(CommandProvider command) { + Player player = command.getPlayer(); + } +} diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java index d187695..c99299f 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java @@ -1,6 +1,7 @@ package zone.themcgamer.discordbot; import com.jagrosh.jdautilities.command.CommandClientBuilder; +import com.jagrosh.jdautilities.command.annotation.JDACommand; import lombok.Getter; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; @@ -39,6 +40,7 @@ public class MGZBot { commandClientBuilder.addCommand(new MessageCommand()); commandClientBuilder.addCommand(new EditMessageCommand()); commandClientBuilder.addCommand(new AddReactionToMessageCommand()); + commandClientBuilder.addCommand(new MemberCountCommand()); try { jda = JDABuilder.createDefault(BotConstants.TOKEN) diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MemberCountCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MemberCountCommand.java new file mode 100644 index 0000000..631b63f --- /dev/null +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MemberCountCommand.java @@ -0,0 +1,39 @@ +package zone.themcgamer.discordbot.command.impl; + +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jdautilities.command.annotation.JDACommand; +import net.dv8tion.jda.api.EmbedBuilder; +import zone.themcgamer.core.cooldown.Cooldown; +import zone.themcgamer.discordbot.command.BaseCommand; +import zone.themcgamer.discordbot.guild.Guild; +import zone.themcgamer.discordbot.utilities.EmbedUtils; + +import java.util.Arrays; +import java.util.List; + +public class MemberCountCommand extends BaseCommand { + + public MemberCountCommand() { + name = "membercount"; + aliases = new String[]{"members"}; + help = "Shows the amount of members in the guild"; + cooldown = 10; + arguments = ""; + guildOnly = true; + guilds = Arrays.asList(Guild.MAIN, Guild.TEAM, Guild.TEST); + } + + @Override + protected void execute(CommandEvent event, List args) { + net.dv8tion.jda.api.entities.Guild guild = event.getGuild(); + guild.loadMembers().onSuccess(members -> { + EmbedBuilder embedBuilder = EmbedUtils.defaultEmbed(); + embedBuilder.setTitle("Member Count"); + embedBuilder.addField("Humans", String.valueOf(members.stream().filter(member -> !member.getUser().isBot()).count()), true); + embedBuilder.addField("Bots", String.valueOf(members.stream().filter(member -> member.getUser().isBot()).count()), true); + + event.getChannel().sendMessage(embedBuilder.build()).queue(); + }); + } +} + diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/events/GuildsListener.java b/discordbot/src/main/java/zone/themcgamer/discordbot/events/GuildsListener.java index 7cc0a46..a412768 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/events/GuildsListener.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/events/GuildsListener.java @@ -140,7 +140,7 @@ public class GuildsListener extends ListenerAdapter { embedBuilder.setDescription(event.getOldPosition() + " -> " + event.getNewPosition()); embedBuilder.addField("Role", role.getAsMention(), false); embedBuilder.addField("Id", role.getId(), false); - embedBuilder.addField("Color", Objects.requireNonNull(role.getColor()).toString(), false); + embedBuilder.addField("Color", String.valueOf(role.getColor().getRGB()), false); embedBuilder.addField("Guild", guild.getName(), true); MessageUtils.sendLogMessage(embedBuilder); }