| 
1 | 1 | package org.togetherjava.tjbot.commands.help;  | 
2 | 2 | 
 
  | 
 | 3 | +import net.dv8tion.jda.api.EmbedBuilder;  | 
3 | 4 | import net.dv8tion.jda.api.JDA;  | 
4 | 5 | import net.dv8tion.jda.api.entities.Guild;  | 
5 | 6 | import net.dv8tion.jda.api.entities.Message;  | 
 | 
13 | 14 | import net.dv8tion.jda.api.utils.messages.MessageEditBuilder;  | 
14 | 15 | import net.dv8tion.jda.api.utils.messages.MessageEditData;  | 
15 | 16 | import net.dv8tion.jda.internal.requests.CompletedRestAction;  | 
 | 17 | +import org.jetbrains.annotations.NonNls;  | 
16 | 18 | import org.slf4j.Logger;  | 
17 | 19 | import org.slf4j.LoggerFactory;  | 
18 | 20 | import org.togetherjava.tjbot.commands.MessageReceiverAdapter;  | 
19 | 21 | import org.togetherjava.tjbot.commands.Routine;  | 
 | 22 | +import org.togetherjava.tjbot.commands.utils.DiscordClientAction;  | 
20 | 23 | import org.togetherjava.tjbot.config.Config;  | 
21 | 24 | 
 
  | 
22 | 25 | import javax.annotation.Nullable;  | 
 | 
39 | 42 | public final class HelpThreadOverviewUpdater extends MessageReceiverAdapter implements Routine {  | 
40 | 43 |     private static final Logger logger = LoggerFactory.getLogger(HelpThreadOverviewUpdater.class);  | 
41 | 44 | 
 
  | 
42 |  | -    private static final String STATUS_TITLE = "## __**Active questions**__ ##";  | 
 | 45 | +    private static final @NonNls String STATUS_TITLE = "## Active questions ##";  | 
43 | 46 |     private static final int OVERVIEW_QUESTION_LIMIT = 150;  | 
44 | 47 |     private static final AtomicInteger FIND_STATUS_MESSAGE_CONSECUTIVE_FAILURES =  | 
45 | 48 |             new AtomicInteger(0);  | 
@@ -120,7 +123,9 @@ private void updateOverview(TextChannel overviewChannel) {  | 
120 | 123 |         logger.debug("Found {} active questions", activeThreads.size());  | 
121 | 124 | 
 
  | 
122 | 125 |         MessageEditData message = new MessageEditBuilder()  | 
123 |  | -            .setContent(STATUS_TITLE + "\n\n" + createDescription(activeThreads))  | 
 | 126 | +            .setEmbeds(new EmbedBuilder().setTitle(STATUS_TITLE)  | 
 | 127 | +                .setDescription(createDescription(activeThreads))  | 
 | 128 | +                .build())  | 
124 | 129 |             .build();  | 
125 | 130 | 
 
  | 
126 | 131 |         getStatusMessage(overviewChannel)  | 
@@ -163,12 +168,13 @@ private static RestAction<Optional<Message>> getStatusMessage(MessageChannel cha  | 
163 | 168 |     }  | 
164 | 169 | 
 
  | 
165 | 170 |     private static boolean isStatusMessage(Message message) {  | 
166 |  | -        if (!message.getAuthor().equals(message.getJDA().getSelfUser())) {  | 
 | 171 | +        if (message.getEmbeds().isEmpty()  | 
 | 172 | +                || !message.getAuthor().equals(message.getJDA().getSelfUser())) {  | 
167 | 173 |             return false;  | 
168 | 174 |         }  | 
169 | 175 | 
 
  | 
170 |  | -        String content = message.getContentRaw();  | 
171 |  | -        return content.startsWith(STATUS_TITLE);  | 
 | 176 | +        String messageEmbedTitle = message.getEmbeds().get(0).getTitle();  | 
 | 177 | +        return STATUS_TITLE.equals(messageEmbedTitle);  | 
172 | 178 |     }  | 
173 | 179 | 
 
  | 
174 | 180 |     private RestAction<Message> sendUpdatedOverview(@Nullable Message statusMessage,  | 
 | 
0 commit comments