diff --git a/src/main/java/handiebot/command/commands/misc/TengwarCommand.java b/src/main/java/handiebot/command/commands/misc/TengwarCommand.java index 8b511ea..127b8a8 100644 --- a/src/main/java/handiebot/command/commands/misc/TengwarCommand.java +++ b/src/main/java/handiebot/command/commands/misc/TengwarCommand.java @@ -6,9 +6,8 @@ import handiebot.utils.MessageUtils; import net.agspace.TengwarImageGenerator; import net.agspace.Translator; -import java.io.FileNotFoundException; - import static handiebot.HandieBot.resourceBundle; +import static handiebot.utils.MessageUtils.sendFile; import static handiebot.utils.MessageUtils.sendMessage; /** @@ -31,17 +30,14 @@ public class TengwarCommand extends ContextCommand { String input = MessageUtils.getTextFromArgs(context.getArgs(), 1); if (context.getArgs()[0].equalsIgnoreCase("to")){ String result = Translator.translateToTengwar(input); - try { - //TODO: replace with rate-limited send method. - context.getChannel().sendFile("Raw text: `" +result+'`', TengwarImageGenerator.generateImage(result, - 600, - 24f, - false, - false, - System.getProperty("user.home")+"/.handiebot/tengwarTemp.png")); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + sendFile(TengwarImageGenerator.generateImage(result, + 600, + 24f, + false, + false, + System.getProperty("user.home")+"/.handiebot/tengwarTemp.png"), + "Raw text: `" +result+'`', + context.getChannel()); } else if (context.getArgs()[0].equalsIgnoreCase("from")){ sendMessage(Translator.translateToEnglish(input), context.getChannel()); } diff --git a/src/main/java/handiebot/lavaplayer/playlist/Playlist.java b/src/main/java/handiebot/lavaplayer/playlist/Playlist.java index 4e2561d..0847e29 100644 --- a/src/main/java/handiebot/lavaplayer/playlist/Playlist.java +++ b/src/main/java/handiebot/lavaplayer/playlist/Playlist.java @@ -120,7 +120,6 @@ public class Playlist { * Gets a 'shuffled index' from a given list length. That means: * - A random number from 0 to (listLength-1) - threshold*(listLength), where threshold is some percentage of * recent songs that should be ignored; for example, the most recent 20% of the playlist can be ignored. - * - A greater likelihood for numbers closer to 0 (those which have not been played in a while). * @param listLength The number of items in a potential list to choose from. * @return A pseudo-random choice as to which item to pick from the list. */ @@ -128,7 +127,6 @@ public class Playlist { float threshold = 0.2f; int trueLength = listLength - (int)(threshold*(float)listLength); Random rand = new Random(); - //TODO Add in a small gradient in chance for a song to be picked. return rand.nextInt(trueLength); } diff --git a/src/main/java/handiebot/utils/MessageUtils.java b/src/main/java/handiebot/utils/MessageUtils.java index 75287ae..2cc3eaa 100644 --- a/src/main/java/handiebot/utils/MessageUtils.java +++ b/src/main/java/handiebot/utils/MessageUtils.java @@ -49,11 +49,11 @@ public class MessageUtils { * @param channel The channel to send the message on. * @return The message that was sent, or null if the file could not be found. */ - public static IMessage sendFile(File file, IChannel channel){ + public static IMessage sendFile(File file, String content, IChannel channel){ return RequestBuffer.request(() -> { IMessage msg = null; try { - msg = channel.sendFile(file); + msg = channel.sendFile(content, file); } catch (FileNotFoundException e) { e.printStackTrace(); }