diff --git a/src/main/java/net/Broken/Commands/Rank.java b/src/main/java/net/Broken/Commands/Rank.java deleted file mode 100644 index dbddd30..0000000 --- a/src/main/java/net/Broken/Commands/Rank.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.Broken.Commands; - -import net.Broken.Commande; -import net.Broken.Tools.UserManager.Stats.UserStatsUtils; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; - -public class Rank implements Commande { - @Override - public void action(String[] args, MessageReceivedEvent event) { - UserStatsUtils userStats = UserStatsUtils.getINSTANCE(); - MessageEmbed msg = userStats.getRankMessage(event.getMember()); - event.getTextChannel().sendMessage(msg).queue(); - } - - @Override - public boolean isPrivateUsable() { - return false; - } - - @Override - public boolean isAdminCmd() { - return false; - } - - /** - * Determines if the command is usable only by bot level admin user - * - * @return boolean - */ - @Override - public boolean isBotAdminCmd() { - return false; - } - - @Override - public boolean isNSFW() { - return false; - } -} diff --git a/src/main/java/net/Broken/Commands/Settings.java b/src/main/java/net/Broken/Commands/Settings.java deleted file mode 100644 index be68a09..0000000 --- a/src/main/java/net/Broken/Commands/Settings.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.Broken.Commands; - -import net.Broken.Commande; -import net.Broken.DB.Repository.GuildPreferenceRepository; -import net.Broken.MainBot; -import net.Broken.SpringContext; -import net.Broken.Tools.EmbedMessageUtils; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.context.ApplicationContext; - -import java.awt.*; - -public class Settings implements Commande { - - private Logger logger = LogManager.getLogger(); - - private GuildPreferenceRepository guildPreferenceRepository; - - public Settings() { - - ApplicationContext context = SpringContext.getAppContext(); - guildPreferenceRepository = (GuildPreferenceRepository) context.getBean("guildPreferenceRepository"); - } - - @Override - public void action(String[] args, MessageReceivedEvent event) { - - EmbedBuilder builder = new EmbedBuilder() - .setTitle("Settings") - .setDescription("You can do all the configuration on the web page in the \"Bot Settings\" menu.\nhttps://" + MainBot.url).setColor(Color.green); - event.getTextChannel().sendMessage(EmbedMessageUtils.buildStandar(builder)).queue(); - - - } - - @Override - public boolean isPrivateUsable() { - return false; - } - - @Override - public boolean isAdminCmd() { - return true; - } - - /** - * Determines if the command is usable only by bot level admin user - * - * @return boolean - */ - @Override - public boolean isBotAdminCmd() { - return false; - } - - @Override - public boolean isNSFW() { - return false; - } -} diff --git a/src/main/java/net/Broken/SlashCommands/Rank.java b/src/main/java/net/Broken/SlashCommands/Rank.java new file mode 100644 index 0000000..ff9b343 --- /dev/null +++ b/src/main/java/net/Broken/SlashCommands/Rank.java @@ -0,0 +1,49 @@ +package net.Broken.SlashCommands; + +import net.Broken.MainBot; +import net.Broken.SlashCommand; +import net.Broken.Tools.UserManager.Stats.UserStatsUtils; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.interactions.commands.build.OptionData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; +import net.dv8tion.jda.api.interactions.components.Button; + +import java.util.List; + +public class Rank implements SlashCommand { + @Override + public void action(SlashCommandEvent event) { + event.deferReply().queue(); + UserStatsUtils userStats = UserStatsUtils.getINSTANCE(); + MessageEmbed messageEmbed = userStats.getRankMessage(event.getMember()); + event.getHook().sendMessageEmbeds(messageEmbed).addActionRow( + Button.link("https://" + MainBot.url + "/rank", "More stats") + ).queue(); + } + + @Override + public String getDescription() { + return "Get the top 5 ranking of this server"; + } + + @Override + public List getOptions() { + return null; + } + + @Override + public List getSubcommands() { + return null; + } + + @Override + public boolean isBotAdminCmd() { + return false; + } + + @Override + public boolean isNSFW() { + return false; + } +} diff --git a/src/main/java/net/Broken/Tools/Command/SlashCommandLoader.java b/src/main/java/net/Broken/Tools/Command/SlashCommandLoader.java index be4a2ca..0a0a061 100644 --- a/src/main/java/net/Broken/Tools/Command/SlashCommandLoader.java +++ b/src/main/java/net/Broken/Tools/Command/SlashCommandLoader.java @@ -50,13 +50,10 @@ public class SlashCommandLoader { NoSuchMethodException e) { logger.error("Failed to load " + name + "!"); } - } - } else { logger.trace("Ignored command: " + name); } - } } @@ -71,5 +68,6 @@ public class SlashCommandLoader { commandListUpdateAction.addCommands(command); }); commandListUpdateAction.queue(); + } } diff --git a/src/main/java/net/Broken/Tools/UserManager/Stats/UserStatsUtils.java b/src/main/java/net/Broken/Tools/UserManager/Stats/UserStatsUtils.java index aaf6187..1b9ca6b 100644 --- a/src/main/java/net/Broken/Tools/UserManager/Stats/UserStatsUtils.java +++ b/src/main/java/net/Broken/Tools/UserManager/Stats/UserStatsUtils.java @@ -249,7 +249,7 @@ public class UserStatsUtils { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setColor(Color.yellow); - embedBuilder.setTitle(member.getGuild().getName() + " Ranking"); + embedBuilder.setTitle(":trophy: " + member.getGuild().getName() + " Ranking"); embedBuilder.addField("Top 5:", stringBuilder.toString(), false); String rank; switch (pack.selfStats.rank) { @@ -269,7 +269,6 @@ public class UserStatsUtils { embedBuilder.addField("Your stats:", rank + " with " + pack.selfStats.total + " points", false); - embedBuilder.addField("More stats:", "https://" + MainBot.url + "/rank", false); return EmbedMessageUtils.buildStandar(embedBuilder); }