1
1
package net .javadiscord .javabot .listener ;
2
2
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 ;
4
5
import net .dv8tion .jda .api .JDA ;
5
6
import net .dv8tion .jda .api .entities .*;
6
7
import net .dv8tion .jda .api .events .message .MessageReceivedEvent ;
7
8
import net .dv8tion .jda .api .hooks .ListenerAdapter ;
8
- import net .dv8tion .jda .api .interactions .components .buttons .Button ;
9
9
import net .dv8tion .jda .api .requests .RestAction ;
10
10
import net .javadiscord .javabot .util .ExceptionLogger ;
11
- import net .javadiscord .javabot .util .InteractionUtils ;
12
- import net .javadiscord .javabot .util .Responses ;
13
11
import net .javadiscord .javabot .util .WebhookUtil ;
14
12
import org .jetbrains .annotations .NotNull ;
13
+ import org .jetbrains .annotations .Nullable ;
15
14
15
+ import java .net .MalformedURLException ;
16
+ import java .net .URL ;
16
17
import java .util .Arrays ;
17
18
import java .util .Optional ;
18
19
import java .util .regex .Matcher ;
@@ -33,12 +34,20 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
33
34
Optional <RestAction <Message >> optional = parseMessageUrl (matcher .group (), event .getJDA ());
34
35
optional .ifPresent (action -> action .queue (
35
36
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" )) )
37
38
), ExceptionLogger ::capture
38
39
));
39
40
}
40
41
}
41
42
43
+ private @ Nullable URL toURL (String url ) {
44
+ try {
45
+ return new URL (url );
46
+ } catch (MalformedURLException e ) {
47
+ return null ;
48
+ }
49
+ }
50
+
42
51
/**
43
52
* Tries to parse a Discord Message Link to the corresponding Message object.
44
53
*
0 commit comments