11package net .javadiscord .javabot .listener ;
22
3- import net .dv8tion .jda .api .EmbedBuilder ;
3+ import club .minnced .discord .webhook .send .component .ActionRow ;
4+ import club .minnced .discord .webhook .send .component .Button ;
45import net .dv8tion .jda .api .JDA ;
56import net .dv8tion .jda .api .entities .*;
67import net .dv8tion .jda .api .events .message .MessageReceivedEvent ;
78import net .dv8tion .jda .api .hooks .ListenerAdapter ;
8- import net .dv8tion .jda .api .interactions .components .buttons .Button ;
99import net .dv8tion .jda .api .requests .RestAction ;
1010import net .javadiscord .javabot .util .ExceptionLogger ;
11- import net .javadiscord .javabot .util .InteractionUtils ;
12- import net .javadiscord .javabot .util .Responses ;
1311import net .javadiscord .javabot .util .WebhookUtil ;
1412import org .jetbrains .annotations .NotNull ;
13+ import org .jetbrains .annotations .Nullable ;
1514
15+ import java .net .MalformedURLException ;
16+ import java .net .URL ;
1617import java .util .Arrays ;
1718import java .util .Optional ;
1819import java .util .regex .Matcher ;
@@ -33,12 +34,20 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
3334 Optional <RestAction <Message >> optional = parseMessageUrl (matcher .group (), event .getJDA ());
3435 optional .ifPresent (action -> action .queue (
3536 m -> WebhookUtil .ensureWebhookExists (event .getChannel ().asTextChannel (),
36- wh -> WebhookUtil .mirrorMessageToWebhook (wh , m , m .getContentRaw () + " \n \n " + m .getJumpUrl (), 0 )
37+ wh -> WebhookUtil .mirrorMessageToWebhook (wh , m , m .getContentRaw (), 0 , ActionRow . of ( Button . link ( toURL ( m .getJumpUrl ()), "Jump to Message" )) )
3738 ), ExceptionLogger ::capture
3839 ));
3940 }
4041 }
4142
43+ private @ Nullable URL toURL (String url ) {
44+ try {
45+ return new URL (url );
46+ } catch (MalformedURLException e ) {
47+ return null ;
48+ }
49+ }
50+
4251 /**
4352 * Tries to parse a Discord Message Link to the corresponding Message object.
4453 *
0 commit comments