diff --git a/src/main/java/wtf/beatrice/hidekobot/Configuration.java b/src/main/java/wtf/beatrice/hidekobot/Configuration.java index 2c6e0d4..ea43355 100644 --- a/src/main/java/wtf/beatrice/hidekobot/Configuration.java +++ b/src/main/java/wtf/beatrice/hidekobot/Configuration.java @@ -17,6 +17,16 @@ public class Configuration private static String botApplicationId = ""; + // discord api returns a broken image if you don't use specific sizes (powers of 2), so we limit it to these + private static final int[] supportedAvatarResolutions = { 16, 32, 64, 128, 256, 512, 1024 }; + + /** + * Get an array of all the Discord-supported avatar resolutions. + * Discord's API returns a broken image if you don't use specific sizes (powers of 2). + * + * @return array of supported resolutions. + */ + public static int[] getSupportedAvatarResolutions() { return supportedAvatarResolutions; } /** * Checks if the bot has been started with the verbose argument. diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/completer/AvatarCompleter.java b/src/main/java/wtf/beatrice/hidekobot/commands/completer/AvatarCompleter.java index 134561c..e85652a 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/completer/AvatarCompleter.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/completer/AvatarCompleter.java @@ -3,7 +3,7 @@ package wtf.beatrice.hidekobot.commands.completer; import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; import net.dv8tion.jda.api.interactions.commands.Command; import org.jetbrains.annotations.NotNull; -import wtf.beatrice.hidekobot.commands.slash.AvatarCommand; +import wtf.beatrice.hidekobot.Configuration; import java.util.ArrayList; import java.util.List; @@ -18,7 +18,7 @@ public class AvatarCompleter List options = new ArrayList<>(); - for(int res : AvatarCommand.acceptedSizes) + for(int res : Configuration.getSupportedAvatarResolutions()) { String resString = String.valueOf(res); String userInput = event.getFocusedOption().getValue(); diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/slash/AvatarCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/slash/AvatarCommand.java index 2e9d420..2ff2716 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/slash/AvatarCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/slash/AvatarCommand.java @@ -5,13 +5,12 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import org.jetbrains.annotations.NotNull; +import wtf.beatrice.hidekobot.Configuration; import java.awt.*; public class AvatarCommand { - // discord api returns a broken image if you don't use specific sizes (powers of 2), so we limit it to these - public static final int[] acceptedSizes = { 16, 32, 64, 128, 256, 512, 1024 }; public AvatarCommand(@NotNull SlashCommandInteractionEvent event) { @@ -20,6 +19,9 @@ public class AvatarCommand User user; int resolution; + int[] acceptedSizes = Configuration.getSupportedAvatarResolutions(); + + OptionMapping userArg = event.getOption("user"); if(userArg != null) {