From 8ca70dac78d75c1b76c1650cb688c35a8753c4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Tue, 20 Dec 2022 00:52:31 +0100 Subject: [PATCH] Fix urban dictionary term not getting parsed correctly for url --- .../commands/message/UrbanDictionaryCommand.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/message/UrbanDictionaryCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/message/UrbanDictionaryCommand.java index 8f26c01..d784016 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/message/UrbanDictionaryCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/message/UrbanDictionaryCommand.java @@ -176,10 +176,9 @@ public class UrbanDictionaryCommand implements MessageCommand } // make it nice to look at, compared to the html value - term = term.replaceAll("\\+", " "); - term = WordUtils.capitalizeFully(term); - + final String finalTerm = term; + term = WordUtils.capitalizeFully(term.replaceAll("\\+", " ")); String serializedMeanings = serialize(plaintextMeanings); String serializedExamples = serialize(plaintextExamples); @@ -194,7 +193,6 @@ public class UrbanDictionaryCommand implements MessageCommand plaintextExamples.get(0), contributorsNames.get(0), submissionDates.get(0), 0); // copy term for async thing - final String finalTerm = term; event.getChannel() .sendMessageEmbeds(embed) .addActionRow(previousPageButton.asDisabled(), //disabled by default because we're on page 0 @@ -243,8 +241,6 @@ public class UrbanDictionaryCommand implements MessageCommand public static void changePage(ButtonInteractionEvent event, boolean increase) { - - String messageId = event.getMessageId(); DatabaseSource database = Cache.getDatabaseSource(); @@ -278,6 +274,8 @@ public class UrbanDictionaryCommand implements MessageCommand page++; else page--; + term = WordUtils.capitalizeFully(term.replaceAll("\\+", " ")); + MessageEmbed updatedEmbed = buildEmbed(term, url, event.getUser(), meanings.get(page), examples.get(page), contributors.get(page), dates.get(page), page);