diff --git a/src/main/java/de/presti/ree6/commands/Category.java b/src/main/java/de/presti/ree6/commands/Category.java index 547459f7b..41d13e1d0 100644 --- a/src/main/java/de/presti/ree6/commands/Category.java +++ b/src/main/java/de/presti/ree6/commands/Category.java @@ -8,34 +8,60 @@ public enum Category { /** * Category used for informativ Commands. */ - INFO, + INFO("re_icon_info",1019221661070917632L, false, "Used to gather information or provide information."), /** * Category used for moderativ Commands. */ - MOD, + MOD("re_icon_mod",1019221710932803624L, false, "Moderation Tools that can help you manager Users or prevent rule breaking on the Server."), /** * Category used for music Commands. */ - MUSIC, + MUSIC("re_icon_music",1019221781762023575L, false, "Music utilities that allow you to have fun with your friends through the power of music!"), /** * Category used for fun Commands. */ - FUN, + FUN("re_icon_fun",1019221814670532628L, false, "Fun utilities that give you the power to do dumb stuff because you can!"), /** * Category used for level Commands. */ - LEVEL, + LEVEL("re_icon_level",1019221845972635809L, false, "Leveling Tools that allow you to keep track of progress on the Server."), /** * Category used for community Commands. */ - COMMUNITY, + COMMUNITY("re_icon_community",1019221884686057552L, false, "Community Tools that allow you to interact with your community."), /** * Category used for NSFW Commands. */ - NSFW, + NSFW("re_icon_nsfw",1019221923466584166L, false, "NSFW stuff that you can only use in NSFW Channels."), /** * Category used for admin Commands. */ - HIDDEN + HIDDEN("re_icon_hidden",1019221957817933865L, false, "Hidden Commands that are only visible to the Owner of the Bot."); + private final String icon; + private final long iconId; + private final boolean iconAnimated; + private final String description; + Category(String icon, long iconId, boolean iconAnimated, String description) { + this.icon = icon; + this.iconId = iconId; + this.iconAnimated = iconAnimated; + this.description = description; + } + + public String getIcon() { + return icon; + } + + public long getIconId() { + return iconId; + } + + public boolean isIconAnimated() { + return iconAnimated; + } + + public String getDescription() { + return description; + } } diff --git a/src/main/java/de/presti/ree6/commands/CommandManager.java b/src/main/java/de/presti/ree6/commands/CommandManager.java index bdf790c72..bd19d813e 100644 --- a/src/main/java/de/presti/ree6/commands/CommandManager.java +++ b/src/main/java/de/presti/ree6/commands/CommandManager.java @@ -19,6 +19,8 @@ import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; import net.dv8tion.jda.api.interactions.commands.build.CommandData; import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageCreateData; import net.dv8tion.jda.internal.interactions.CommandDataImpl; import org.reflections.Reflections; @@ -41,10 +43,10 @@ public class CommandManager { * Constructor for the Command-Manager used to register every Command. * * @throws CommandInitializerException if an error occurs while initializing the Commands. - * @throws IllegalStateException if an Invalid Command was used to initialize. - * @throws IllegalAccessException when an Instance of a Command is not accessible. - * @throws InstantiationException when an Instance of a Command is not instantiable. - * @throws NoSuchMethodException when a Constructor Instance of a Command is not found. + * @throws IllegalStateException if an Invalid Command was used to initialize. + * @throws IllegalAccessException when an Instance of a Command is not accessible. + * @throws InstantiationException when an Instance of a Command is not instantiable. + * @throws NoSuchMethodException when a Constructor Instance of a Command is not found. */ public CommandManager() throws CommandInitializerException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { Main.getInstance().getLogger().info("Initializing Commands!"); @@ -206,11 +208,12 @@ public boolean perform(Member member, Guild guild, String messageContent, Messag /** * Perform a Message based Command. - * @param member the Member that performed the command. - * @param guild the Guild the Member is from. + * + * @param member the Member that performed the command. + * @param guild the Guild the Member is from. * @param messageContent the Message content (including the prefix + command name). - * @param message the Message Entity. - * @param textChannel the TextChannel where the command has been performed. + * @param message the Message Entity. + * @param textChannel the TextChannel where the command has been performed. * @return true, if a command has been performed. */ private boolean performMessageCommand(Member member, Guild guild, String messageContent, Message message, MessageChannelUnion textChannel) { @@ -258,7 +261,7 @@ private boolean performMessageCommand(Member member, Guild guild, String message /** * Call when a slash command has been performed. * - * @param textChannel the TextChannel where the command has been performed. + * @param textChannel the TextChannel where the command has been performed. * @param slashCommandInteractionEvent the Slash-Command Event. */ private boolean performSlashCommand(MessageChannelUnion textChannel, SlashCommandInteractionEvent slashCommandInteractionEvent) { @@ -285,6 +288,7 @@ private boolean performSlashCommand(MessageChannelUnion textChannel, SlashComman /** * Check if an User is time-outed. + * * @param user the User. * @return true, if yes | false, if not. */ @@ -292,6 +296,85 @@ public boolean isTimeout(User user) { return ArrayUtil.commandCooldown.contains(user.getId()) && BotWorker.getVersion() != BotVersion.DEVELOPMENT_BUILD; } + /** + * Send a message to a special Message-Channel. + * + * @param messageCreateData the Message content. + * @param commandEvent the Command-Event. + */ + public void sendMessage(MessageCreateData messageCreateData, CommandEvent commandEvent) { + sendMessage(messageCreateData, commandEvent.getChannel(), commandEvent.getInteractionHook()); + } + + /** + * Send a message to a special Message-Channel. + * + * @param messageCreateData the Message content. + * @param deleteSecond the delete delay + * @param commandEvent the Command-Event. + */ + public void sendMessage(MessageCreateData messageCreateData, int deleteSecond, CommandEvent commandEvent) { + sendMessage(messageCreateData, deleteSecond, commandEvent.getChannel(), commandEvent.getInteractionHook()); + } + + /** + * Send a message to a special Message-Channel. + * + * @param messageCreateData the Message content. + * @param messageChannel the Message-Channel. + */ + public void sendMessage(MessageCreateData messageCreateData, MessageChannel messageChannel) { + sendMessage(messageCreateData, messageChannel, null); + } + + /** + * Send a message to a special Message-Channel, with a deletion delay. + * + * @param messageCreateData the Message content. + * @param deleteSecond the delete delay + * @param messageChannel the Message-Channel. + */ + public void sendMessage(MessageCreateData messageCreateData, int deleteSecond, MessageChannel messageChannel) { + sendMessage(messageCreateData, deleteSecond, messageChannel, null); + } + + /** + * Send a message to a special Message-Channel. + * + * @param messageCreateData the Message content. + * @param messageChannel the Message-Channel. + * @param interactionHook the Interaction-hook if it is a slash command. + */ + public void sendMessage(MessageCreateData messageCreateData, MessageChannel messageChannel, InteractionHook interactionHook) { + if (interactionHook == null) { + if (messageChannel.canTalk()) messageChannel.sendMessage(messageCreateData).queue(); + } else interactionHook.sendMessage(messageCreateData).queue(); + } + + /** + * Send a message to a special Message-Channel, with a deletion delay. + * + * @param messageCreateData the Message content. + * @param messageChannel the Message-Channel. + * @param interactionHook the Interaction-hook if it is a slash command. + * @param deleteSecond the delete delay + */ + public void sendMessage(MessageCreateData messageCreateData, int deleteSecond, MessageChannel messageChannel, InteractionHook interactionHook) { + if (interactionHook == null) { + if (messageChannel == null) return; + if (messageChannel.canTalk()) + messageChannel.sendMessage(messageCreateData).delay(deleteSecond, TimeUnit.SECONDS).flatMap(message -> { + if (message != null && message.getChannel().retrieveMessageById(message.getId()).complete() != null) { + return message.delete(); + } + + return null; + }).queue(); + } else { + interactionHook.sendMessage(messageCreateData).queue(); + } + } + /** * Send a message to a special Message-Channel. * @@ -299,7 +382,7 @@ public boolean isTimeout(User user) { * @param messageChannel the Message-Channel. */ public void sendMessage(String message, MessageChannel messageChannel) { - if (messageChannel.canTalk()) sendMessage(message, messageChannel, null); + sendMessage(message, messageChannel, null); } /** @@ -310,7 +393,7 @@ public void sendMessage(String message, MessageChannel messageChannel) { * @param messageChannel the Message-Channel. */ public void sendMessage(String message, int deleteSecond, MessageChannel messageChannel) { - if (messageChannel.canTalk()) sendMessage(message, deleteSecond, messageChannel, null); + sendMessage(message, deleteSecond, messageChannel, null); } /** @@ -321,9 +404,7 @@ public void sendMessage(String message, int deleteSecond, MessageChannel message * @param interactionHook the Interaction-hook if it is a slash command. */ public void sendMessage(String message, MessageChannel messageChannel, InteractionHook interactionHook) { - if (interactionHook == null) { - if (messageChannel.canTalk()) messageChannel.sendMessage(message).queue(); - } else interactionHook.sendMessage(message).queue(); + sendMessage(new MessageCreateBuilder().setContent(message).build(), messageChannel, interactionHook); } /** @@ -335,19 +416,7 @@ public void sendMessage(String message, MessageChannel messageChannel, Interacti * @param deleteSecond the delete delay */ public void sendMessage(String messageContent, int deleteSecond, MessageChannel messageChannel, InteractionHook interactionHook) { - if (interactionHook == null) { - if (messageChannel == null) return; - if (messageChannel.canTalk()) - messageChannel.sendMessage(messageContent).delay(deleteSecond, TimeUnit.SECONDS).flatMap(message -> { - if (message != null && message.getChannel().retrieveMessageById(message.getId()).complete() != null) { - return message.delete(); - } - - return null; - }).queue(); - } else { - interactionHook.sendMessage(messageContent).queue(); - } + sendMessage(new MessageCreateBuilder().setContent(messageContent).build(), deleteSecond, messageChannel, interactionHook); } /** @@ -357,7 +426,7 @@ public void sendMessage(String messageContent, int deleteSecond, MessageChannel * @param messageChannel the Message-Channel. */ public void sendMessage(EmbedBuilder embedBuilder, MessageChannel messageChannel) { - if (messageChannel.canTalk()) sendMessage(embedBuilder, messageChannel, null); + sendMessage(embedBuilder, messageChannel, null); } /** @@ -368,7 +437,7 @@ public void sendMessage(EmbedBuilder embedBuilder, MessageChannel messageChannel * @param messageChannel the Message-Channel. */ public void sendMessage(EmbedBuilder embedBuilder, int deleteSecond, MessageChannel messageChannel) { - if (messageChannel.canTalk()) sendMessage(embedBuilder, deleteSecond, messageChannel, null); + sendMessage(embedBuilder, deleteSecond, messageChannel, null); } /** @@ -379,9 +448,7 @@ public void sendMessage(EmbedBuilder embedBuilder, int deleteSecond, MessageChan * @param interactionHook the Interaction-hook if it is a slash command. */ public void sendMessage(EmbedBuilder embedBuilder, MessageChannel messageChannel, InteractionHook interactionHook) { - if (interactionHook == null) { - if (messageChannel.canTalk()) messageChannel.sendMessageEmbeds(embedBuilder.build()).queue(); - } else interactionHook.sendMessageEmbeds(embedBuilder.build()).queue(); + sendMessage(new MessageCreateBuilder().setEmbeds(embedBuilder.build()).build(), messageChannel, interactionHook); } /** @@ -393,19 +460,7 @@ public void sendMessage(EmbedBuilder embedBuilder, MessageChannel messageChannel * @param interactionHook the Interaction-hook if it is a slash command. */ public void sendMessage(EmbedBuilder embedBuilder, int deleteSecond, MessageChannel messageChannel, InteractionHook interactionHook) { - if (interactionHook == null) { - if (messageChannel == null) return; - if (messageChannel.canTalk()) - messageChannel.sendMessageEmbeds(embedBuilder.build()).delay(deleteSecond, TimeUnit.SECONDS).flatMap(message -> { - if (message != null && message.getChannel().retrieveMessageById(message.getId()).complete() != null) { - return message.delete(); - } - - return null; - }).queue(); - } else { - interactionHook.sendMessageEmbeds(embedBuilder.build()).queue(); - } + sendMessage(new MessageCreateBuilder().setEmbeds(embedBuilder.build()).build(), deleteSecond, messageChannel, interactionHook); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/community/Birthday.java b/src/main/java/de/presti/ree6/commands/impl/community/Birthday.java index e10dd5c95..9ec0cc733 100644 --- a/src/main/java/de/presti/ree6/commands/impl/community/Birthday.java +++ b/src/main/java/de/presti/ree6/commands/impl/community/Birthday.java @@ -29,6 +29,7 @@ public void onPerform(CommandEvent commandEvent) { if (commandEvent.getArguments()[0].equalsIgnoreCase("remove")) { Main.getInstance().getSqlConnector().getSqlWorker().removeBirthday(commandEvent.getGuild().getId(), commandEvent.getMember().getId()); Main.getInstance().getCommandManager().sendMessage("Your Birthday has been removed!", 5, commandEvent.getChannel(), commandEvent.getInteractionHook()); + } else { Main.getInstance().getCommandManager().sendMessage("Please use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "birthday add/remove [Birthday(day.month.year)] [@User]", 5, commandEvent.getChannel(), commandEvent.getInteractionHook()); } diff --git a/src/main/java/de/presti/ree6/commands/impl/hidden/Addon.java b/src/main/java/de/presti/ree6/commands/impl/hidden/Addon.java index dd1702ec8..7795cbb2f 100644 --- a/src/main/java/de/presti/ree6/commands/impl/hidden/Addon.java +++ b/src/main/java/de/presti/ree6/commands/impl/hidden/Addon.java @@ -20,6 +20,7 @@ public class Addon implements ICommand { public void onPerform(CommandEvent commandEvent) { if(commandEvent.getMember().getUser().getId().equalsIgnoreCase("321580743488831490")) { if (commandEvent.getArguments().length == 0) { + StringBuilder stringBuilder = new StringBuilder("```"); for (de.presti.ree6.addons.Addon addon : Main.getInstance().getAddonManager().addons) { stringBuilder.append(addon.getName()).append("v").append(addon.getVersion()) diff --git a/src/main/java/de/presti/ree6/commands/impl/info/Credits.java b/src/main/java/de/presti/ree6/commands/impl/info/Credits.java index a522743b8..5526fcf73 100644 --- a/src/main/java/de/presti/ree6/commands/impl/info/Credits.java +++ b/src/main/java/de/presti/ree6/commands/impl/info/Credits.java @@ -5,7 +5,10 @@ import de.presti.ree6.commands.interfaces.Command; import de.presti.ree6.commands.interfaces.ICommand; import de.presti.ree6.main.Main; +import de.presti.ree6.utils.others.RandomUtils; import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * A command to give credits. @@ -18,8 +21,10 @@ public class Credits implements ICommand { */ @Override public void onPerform(CommandEvent commandEvent) { - Main.getInstance().getCommandManager().sendMessage("Lead Developer : Presti | 平和#0240\nSupport Developer : xazed | xazed#5014\ndavid. | david.#3120", - commandEvent.getChannel(), commandEvent.getInteractionHook()); + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + messageCreateBuilder.addActionRow(Button.link("https://www.ree6.de/#team", + "Meet " + (RandomUtils.secureRandom.nextInt(10000) == 1562 ? "the Spy" : "our Team") + "!")); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/info/Help.java b/src/main/java/de/presti/ree6/commands/impl/info/Help.java index 5aaa68c51..dde25f14d 100644 --- a/src/main/java/de/presti/ree6/commands/impl/info/Help.java +++ b/src/main/java/de/presti/ree6/commands/impl/info/Help.java @@ -5,13 +5,17 @@ import de.presti.ree6.commands.CommandEvent; import de.presti.ree6.commands.interfaces.Command; import de.presti.ree6.commands.interfaces.ICommand; -import de.presti.ree6.utils.data.Data; import de.presti.ree6.main.Main; +import de.presti.ree6.utils.data.Data; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.CommandData; import net.dv8tion.jda.api.interactions.commands.build.OptionData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import net.dv8tion.jda.internal.interactions.CommandDataImpl; /** @@ -50,17 +54,19 @@ public void onPerform(CommandEvent commandEvent) { * @param commandEvent The command event. */ public void sendHelpInformation(String categoryString, CommandEvent commandEvent) { + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + EmbedBuilder em = new EmbedBuilder(); em.setColor(BotWorker.randomEmbedColor()); - em.setTitle("Command Index"); + em.setTitle("Help Center"); em.setThumbnail(commandEvent.getGuild().getJDA().getSelfUser().getAvatarUrl()); em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl()); - if (categoryString == null) { for (Category cat : Category.values()) { if (cat != Category.HIDDEN) { - em.addField("**" + cat.name().toUpperCase().charAt(0) + cat.name().substring(1).toLowerCase() + "**", Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "help " + cat.name().toLowerCase(), true); + String formattedName = cat.name().toUpperCase().charAt(0) + cat.name().substring(1).toLowerCase(); + em.addField("**" + formattedName + "**", Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "help " + cat.name().toLowerCase(), true); } } } else { @@ -69,12 +75,12 @@ public void sendHelpInformation(String categoryString, CommandEvent commandEvent Category category = getCategoryFromString(categoryString); for (ICommand cmd : Main.getInstance().getCommandManager().getCommands().stream().filter(command -> command.getClass().getAnnotation(Command.class).category() == category).toList()) { - end.append("``") - .append(Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue()) - .append(cmd.getClass().getAnnotation(Command.class).name()) - .append("``\n") - .append(cmd.getClass().getAnnotation(Command.class).description()) - .append("\n\n"); + end.append("``") + .append(Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue()) + .append(cmd.getClass().getAnnotation(Command.class).name()) + .append("``\n") + .append(cmd.getClass().getAnnotation(Command.class).description()) + .append("\n\n"); } em.setDescription(end.toString()); @@ -84,7 +90,18 @@ public void sendHelpInformation(String categoryString, CommandEvent commandEvent } } - Main.getInstance().getCommandManager().sendMessage(em, commandEvent.getChannel(), commandEvent.getInteractionHook()); + messageCreateBuilder + .addActionRow( + Button.of(ButtonStyle.LINK, "https://invite.ree6.de", "Invite", + Emoji.fromCustom("re_icon_invite", 1019234807844175945L, false)), + Button.of(ButtonStyle.LINK, "https://support.ree6.de", "Support", + Emoji.fromCustom("re_icon_help", 1019234684745564170L, false)), + Button.of(ButtonStyle.LINK, "https://github.ree6.de", "Github", + Emoji.fromCustom("re_icon_github", 492259724079792138L, false)) + ); + + messageCreateBuilder.setEmbeds(em.build()); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent.getChannel(), commandEvent.getInteractionHook()); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/info/Invite.java b/src/main/java/de/presti/ree6/commands/impl/info/Invite.java index 45150d5d8..2567bb637 100644 --- a/src/main/java/de/presti/ree6/commands/impl/info/Invite.java +++ b/src/main/java/de/presti/ree6/commands/impl/info/Invite.java @@ -5,7 +5,11 @@ import de.presti.ree6.commands.interfaces.Command; import de.presti.ree6.commands.interfaces.ICommand; import de.presti.ree6.main.Main; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * A command to show you an invitation link for Ree6. @@ -18,7 +22,10 @@ public class Invite implements ICommand { */ @Override public void onPerform(CommandEvent commandEvent) { - Main.getInstance().getCommandManager().sendMessage("https://invite.ree6.de", commandEvent.getChannel(), commandEvent.getInteractionHook()); + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + messageCreateBuilder.addActionRow(Button.of(ButtonStyle.LINK, "https://invite.ree6.de", "Invite", + Emoji.fromCustom("re_icon_invite", 1019234807844175945L, false))); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/info/Support.java b/src/main/java/de/presti/ree6/commands/impl/info/Support.java index 95367ae23..90a19fbfa 100644 --- a/src/main/java/de/presti/ree6/commands/impl/info/Support.java +++ b/src/main/java/de/presti/ree6/commands/impl/info/Support.java @@ -5,7 +5,11 @@ import de.presti.ree6.commands.interfaces.Command; import de.presti.ree6.commands.interfaces.ICommand; import de.presti.ree6.main.Main; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * A command to get information about how to contact the Support of Ree6. @@ -18,7 +22,10 @@ public class Support implements ICommand { */ @Override public void onPerform(CommandEvent commandEvent) { - Main.getInstance().getCommandManager().sendMessage("Join our Support Discord Server!\nhttps://support.ree6.de/", commandEvent.getChannel(), commandEvent.getInteractionHook()); + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + messageCreateBuilder.addActionRow(Button.of(ButtonStyle.LINK, "https://support.ree6.de", "Support", + Emoji.fromCustom("re_icon_help", 1019234684745564170L, false))); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/level/Leaderboards.java b/src/main/java/de/presti/ree6/commands/impl/level/Leaderboards.java index c46a4f552..2f31c263d 100644 --- a/src/main/java/de/presti/ree6/commands/impl/level/Leaderboards.java +++ b/src/main/java/de/presti/ree6/commands/impl/level/Leaderboards.java @@ -6,6 +6,8 @@ import de.presti.ree6.commands.interfaces.ICommand; import de.presti.ree6.main.Main; import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * A command to get the Leaderboard. @@ -18,12 +20,14 @@ public class Leaderboards implements ICommand { */ @Override public void onPerform(CommandEvent commandEvent) { - Main.getInstance().getCommandManager().sendMessage("For the leaderboards of this Server visit:\n" + - "voice leaderboard: \n" + - "chat leaderboard: \n" + - "Please noted that you have to be logged in to see these stats, reason for this is Discords Guidelines.\n" + - "If you want to read more about this please visit: ", - commandEvent.getChannel(), commandEvent.getInteractionHook()); + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + messageCreateBuilder.setContent("Below this Message you can find the Leaderboards of the current Server!\nPlease note that you have to be logged in to see these stats, reason for this is Discords Guidelines!"); + messageCreateBuilder.addActionRow( + Button.link("https://support-dev.discord.com/hc/de/articles/360043053492-Statistics-Bot-Policy", "Discord Guidelines"), + Button.link("https://cp.ree6.de/leaderboard/chat?guildId=" + commandEvent.getGuild().getId(), "Chat-Leaderboards"), + Button.link("https://cp.ree6.de/leaderboard/voice?guildId=" + commandEvent.getGuild().getId(), "Voice-Leaderboards") + ); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent); } /** diff --git a/src/main/java/de/presti/ree6/commands/impl/mod/Webinterface.java b/src/main/java/de/presti/ree6/commands/impl/mod/Webinterface.java index 037576c1c..c6cef02f1 100644 --- a/src/main/java/de/presti/ree6/commands/impl/mod/Webinterface.java +++ b/src/main/java/de/presti/ree6/commands/impl/mod/Webinterface.java @@ -5,8 +5,9 @@ import de.presti.ree6.commands.interfaces.Command; import de.presti.ree6.commands.interfaces.ICommand; import de.presti.ree6.main.Main; -import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * Sends a link to the Webinterface. @@ -19,13 +20,9 @@ public class Webinterface implements ICommand { */ @Override public void onPerform(CommandEvent commandEvent) { - - if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR) && commandEvent.getMember().hasPermission(Permission.MANAGE_SERVER)) { - Main.getInstance().getCommandManager().sendMessage("Please visit ", 5, commandEvent.getChannel(), commandEvent.getInteractionHook()); - } else { - Main.getInstance().getCommandManager().sendMessage("You can't use this Command you need the following Permissions: Administrator and Manage Server", 5, commandEvent.getChannel(), commandEvent.getInteractionHook()); - } - Main.getInstance().getCommandManager().deleteMessage(commandEvent.getMessage(), commandEvent.getInteractionHook()); + MessageCreateBuilder messageCreateBuilder = new MessageCreateBuilder(); + messageCreateBuilder.addActionRow(Button.link("https://webinterface.ree6.de", "Webinterface")); + Main.getInstance().getCommandManager().sendMessage(messageCreateBuilder.build(), commandEvent); } /** diff --git a/src/main/java/de/presti/ree6/main/Main.java b/src/main/java/de/presti/ree6/main/Main.java index 268b3804e..9709780d3 100644 --- a/src/main/java/de/presti/ree6/main/Main.java +++ b/src/main/java/de/presti/ree6/main/Main.java @@ -181,7 +181,7 @@ public static void main(String[] args) { // Create a new Instance of the Bot, as well as add the Events. try { - BotWorker.createBot(BotVersion.RELEASE, "1.9.6"); + BotWorker.createBot(BotVersion.DEVELOPMENT_BUILD, "1.9.6"); instance.musicWorker = new MusicWorker(); instance.addEvents(); } catch (Exception ex) {