2
2
3
3
import net .dv8tion .jda .api .EmbedBuilder ;
4
4
import net .dv8tion .jda .api .JDA ;
5
- import net .dv8tion .jda .api .entities .MessageChannel ;
6
- import net .dv8tion .jda .api .entities .MessageEmbed ;
7
- import net .dv8tion .jda .api .entities .TextChannel ;
8
- import net .dv8tion .jda .api .entities .User ;
5
+ import net .dv8tion .jda .api .entities .*;
9
6
import net .dv8tion .jda .api .requests .RestAction ;
10
7
import net .dv8tion .jda .api .requests .restaction .MessageAction ;
11
8
import org .jetbrains .annotations .NotNull ;
@@ -60,6 +57,7 @@ public void runRoutine(@NotNull JDA jda) {
60
57
sendReminder (jda , pendingReminder .getId (), pendingReminder .getChannelId (),
61
58
pendingReminder .getAuthorId (), pendingReminder .getContent (),
62
59
pendingReminder .getCreatedAt ());
60
+
63
61
pendingReminder .delete ();
64
62
}));
65
63
}
@@ -86,16 +84,13 @@ private static RestAction<ReminderRoute> computeReminderRoute(@NotNull JDA jda,
86
84
long authorId , @ NotNull TextChannel channel ) {
87
85
return jda .retrieveUserById (authorId )
88
86
.onErrorMap (error -> null )
89
- .map (author -> new ReminderRoute (channel , author ,
90
- author == null ? null : author .getAsMention ()));
87
+ .map (author -> ReminderRoute .toPublic (channel , author ));
91
88
}
92
89
93
90
private static @ NotNull RestAction <ReminderRoute > createDmReminderRoute (@ NotNull JDA jda ,
94
91
long authorId ) {
95
92
return jda .openPrivateChannelById (authorId )
96
- .map (channel -> new ReminderRoute (channel , channel .getUser (),
97
- "(Sending your reminder directly, because I was unable to"
98
- + " locate the original channel you wanted it to be send to)" ));
93
+ .map (channel -> ReminderRoute .toPrivate (channel , channel .getUser ()));
99
94
}
100
95
101
96
private static void sendReminderViaRoute (@ NotNull RestAction <ReminderRoute > routeAction ,
@@ -133,5 +128,15 @@ private static void sendReminderViaRoute(@NotNull RestAction<ReminderRoute> rout
133
128
134
129
private record ReminderRoute (@ NotNull MessageChannel channel , @ Nullable User target ,
135
130
@ Nullable String description ) {
131
+ static ReminderRoute toPublic (@ NotNull TextChannel channel , @ Nullable User target ) {
132
+ return new ReminderRoute (channel , target ,
133
+ target == null ? null : target .getAsMention ());
134
+ }
135
+
136
+ static ReminderRoute toPrivate (@ NotNull PrivateChannel channel , @ NotNull User target ) {
137
+ return new ReminderRoute (channel , target ,
138
+ "(Sending your reminder directly, because I was unable to locate"
139
+ + " the original channel you wanted it to be send to)" );
140
+ }
136
141
}
137
142
}
0 commit comments