/
GuildMessageChannel.java
706 lines (686 loc) · 34.5 KB
/
GuildMessageChannel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
package net.dv8tion.jda.api.entities;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.sticker.GuildSticker;
import net.dv8tion.jda.api.entities.sticker.Sticker;
import net.dv8tion.jda.api.entities.sticker.StickerSnowflake;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.exceptions.MissingAccessException;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import net.dv8tion.jda.internal.utils.Checks;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* Represents all message channels present in guilds.
*
* This includes channels that are not included in {@link BaseGuildMessageChannel BaseGuildMessageChannel}, such as {@link ThreadChannel}.
*
* @see BaseGuildMessageChannel
*
*/
public interface GuildMessageChannel extends GuildChannel, MessageChannel
{
@Override
default boolean canTalk()
{
return canTalk(getGuild().getSelfMember());
}
/**
* Whether the specified {@link net.dv8tion.jda.api.entities.Member}
* can send messages in this channel.
* <br>Checks for both {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} and
* {@link net.dv8tion.jda.api.Permission#MESSAGE_SEND Permission.MESSAGE_SEND}.
*
* @param member
* The Member to check
*
* @return True, if the specified member is able to read and send messages in this channel
*/
boolean canTalk(@Nonnull Member member);
/**
* Attempts to remove the reaction from a message represented by the specified {@code messageId}
* in this MessageChannel.
*
* <p>The unicode provided has to be a unicode representation of the emoji
* that is supposed to be represented by the Reaction.
* <br>To retrieve the characters needed you can use an api or
* the official discord client by escaping the emoji (\:emoji-name:)
* and copying the resulting emoji from the sent message.
*
* <p>This method encodes the provided unicode for you.
* <b>Do not encode the emoji before providing the unicode.</b>
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI}
* <br>The provided unicode character does not refer to a known emoji unicode character.
* <br>Proper unicode characters for emojis can be found here:
* <a href="https://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">Emoji Table</a></li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or
* the message it referred to has already been deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>The request was attempted after the channel was deleted.</li>
* </ul>
*
* @param messageId
* The messageId to remove the reaction from
* @param unicode
* The unicode characters of the emoji
* @param user
* The target user of which to remove from
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If provided {@code messageId} is {@code null} or empty.</li>
* <li>If provided {@code unicode} is {@code null} or empty.</li>
* </ul>
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.api.requests.RestAction}
*/
@Nonnull
@CheckReturnValue
RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull String unicode, @Nonnull User user);
/**
* Attempts to remove the reaction from a message represented by the specified {@code messageId}
* in this MessageChannel.
*
* <p>The unicode provided has to be a unicode representation of the emoji
* that is supposed to be represented by the Reaction.
* <br>To retrieve the characters needed you can use an api or
* the official discord client by escaping the emoji (\:emoji-name:)
* and copying the resulting emoji from the sent message.
*
* <p>This method encodes the provided unicode for you.
* <b>Do not encode the emoji before providing the unicode.</b>
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI}
* <br>The provided unicode character does not refer to a known emoji unicode character.
* <br>Proper unicode characters for emojis can be found here:
* <a href="https://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">Emoji Table</a></li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or
* the message it referred to has already been deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>The request was attempted after the channel was deleted.</li>
* </ul>
*
* @param messageId
* The messageId to remove the reaction from
* @param unicode
* The unicode characters of the emoji
* @param user
* The target user of which to remove from
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If provided {@code messageId} is {@code null} or empty.</li>
* <li>If provided {@code unicode} is {@code null} or empty.</li>
* </ul>
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.api.requests.RestAction}
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> removeReactionById(long messageId, @Nonnull String unicode, @Nonnull User user)
{
return removeReactionById(Long.toUnsignedString(messageId), unicode, user);
}
/**
* Attempts to remove the reaction from a message represented by the specified {@code messageId}
* in this MessageChannel.
*
* <p><b>An Emote is not the same as an emoji!</b>
* <br>Emotes are custom guild-specific images unlike global unicode emojis!
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI}
* <br>The provided unicode character does not refer to a known emoji unicode character.
* <br>Proper unicode characters for emojis can be found here:
* <a href="https://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">Emoji Table</a></li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or
* the message it referred to has already been deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>The request was attempted after the channel was deleted.</li>
* </ul>
*
* @param messageId
* The messageId to remove the reaction from
* @param emote
* The emote to remove
* @param user
* The target user of which to remove from
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If provided {@code messageId} is {@code null} or empty.</li>
* <li>If provided {@code emote} is {@code null}.</li>
* </ul>
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.api.requests.RestAction}
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull Emote emote, @Nonnull User user)
{
Checks.notNull(emote, "Emote");
return removeReactionById(messageId, emote.getName() + ":" + emote.getId(), user);
}
/**
* Attempts to remove the reaction from a message represented by the specified {@code messageId}
* in this MessageChannel.
*
* <p><b>An Emote is not the same as an emoji!</b>
* <br>Emotes are custom guild-specific images unlike global unicode emojis!
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI}
* <br>The provided unicode character does not refer to a known emoji unicode character.
* <br>Proper unicode characters for emojis can be found here:
* <a href="https://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">Emoji Table</a></li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The provided {@code messageId} is unknown in this MessageChannel, either due to the id being invalid, or
* the message it referred to has already been deleted.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>The request was attempted after the channel was deleted.</li>
* </ul>
*
* @param messageId
* The messageId to remove the reaction from
* @param emote
* The emote to remove
* @param user
* The target user of which to remove from
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If provided {@code messageId} is {@code null} or empty.</li>
* <li>If provided {@code emote} is {@code null}.</li>
* </ul>
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.api.requests.RestAction}
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> removeReactionById(long messageId, @Nonnull Emote emote, @Nonnull User user)
{
return removeReactionById(Long.toUnsignedString(messageId), emote, user);
}
/**
* Bulk deletes a list of messages.
* <b>This is not the same as calling {@link net.dv8tion.jda.api.entities.Message#delete()} in a loop.</b>
* <br>This is much more efficient, but it has a different ratelimit. You may call this once per second per Guild.
*
* <p>Must be at least 2 messages and not be more than 100 messages at a time.
* <br>If you only have 1 message, use the {@link Message#delete()} method instead.
*
* <br><p>You must have the Permission {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} in this channel to use
* this function.
*
* <p>This method is best used when using {@link MessageHistory MessageHistory} to delete a large amount
* of messages. If you have a large amount of messages but only their message Ids, please use {@link #deleteMessagesByIds(Collection)}
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>if any of the provided messages does not exist</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in the channel.</li>
* </ul>
*
* @param messages
* The collection of messages to delete.
*
* @throws IllegalArgumentException
* If the size of the list less than 2 or more than 100 messages.
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If this account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @see #deleteMessagesByIds(Collection)
* @see #purgeMessages(List)
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> deleteMessages(@Nonnull Collection<Message> messages)
{
Checks.notEmpty(messages, "Messages collection");
return deleteMessagesByIds(messages.stream()
.map(ISnowflake::getId)
.collect(Collectors.toList()));
}
/**
* Bulk deletes a list of messages.
* <b>This is not the same as calling {@link net.dv8tion.jda.api.entities.MessageChannel#deleteMessageById(String)} in a loop.</b>
* <br>This is much more efficient, but it has a different ratelimit. You may call this once per second per Guild.
*
* <p>Must be at least 2 messages and not be more than 100 messages at a time.
* <br>If you only have 1 message, use the {@link net.dv8tion.jda.api.entities.Message#delete()} method instead.
*
* <br><p>You must have {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel to use
* this function.
*
* <p>This method is best used when you have a large amount of messages but only their message Ids. If you are using
* {@link MessageHistory MessageHistory} or have {@link net.dv8tion.jda.api.entities.Message Message}
* objects, it would be easier to use {@link #deleteMessages(java.util.Collection)}.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>if any of the provided messages does not exist</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in the channel.</li>
* </ul>
*
* @param messageIds
* The message ids for the messages to delete.
*
* @throws java.lang.IllegalArgumentException
* If the size of the list less than 2 or more than 100 messages.
* @throws java.lang.NumberFormatException
* If any of the provided ids cannot be parsed by {@link Long#parseLong(String)}
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If this account does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @see #deleteMessages(Collection)
* @see #purgeMessagesById(List)
*/
@Nonnull
@CheckReturnValue
RestAction<Void> deleteMessagesByIds(@Nonnull Collection<String> messageIds);
/**
* Attempts to remove all reactions from a message with the specified {@code messageId} in this TextChannel
* <br>This is useful for moderator commands that wish to remove all reactions at once from a specific message.
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The clear-reactions request was attempted after the account lost {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
* in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when adding the reaction.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* The clear-reactions request was attempted after the Message had been deleted.</li>
* </ul>
*
* @param messageId
* The not-empty valid message id
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
* @throws java.lang.IllegalArgumentException
* If the provided {@code id} is {@code null} or empty.
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@Nonnull
@CheckReturnValue
RestAction<Void> clearReactionsById(@Nonnull String messageId);
/**
* Attempts to remove all reactions from a message with the specified {@code messageId} in this TextChannel
* <br>This is useful for moderator commands that wish to remove all reactions at once from a specific message.
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The clear-reactions request was attempted after the account lost {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
* in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} when adding the reaction.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* The clear-reactions request was attempted after the Message had been deleted.</li>
* </ul>
*
* @param messageId
* The message id
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> clearReactionsById(long messageId)
{
return clearReactionsById(Long.toUnsignedString(messageId));
}
/**
* Removes all reactions for the specified emoji.
*
* <h4>Example</h4>
* <pre><code>
* // custom
* channel.clearReactions(messageId, "minn:245267426227388416").queue();
* // unicode escape
* channel.clearReactions(messageId, "\uD83D\uDE02").queue();
* // codepoint notation
* channel.clearReactions(messageId, "U+1F602").queue();
* </code></pre>
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account lost access to the channel by either being removed from the guild
* or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>The provided unicode emoji doesn't exist. Try using one of the example formats.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The message was deleted.</li>
* </ul>
*
* @param messageId
* The id for the target message
* @param unicode
* The unicode emoji to remove reactions for
*
* @throws InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MESSAGE_MANAGE} in the channel
* @throws IllegalArgumentException
* If provided with null
*
* @return {@link RestAction}
*
* @since 4.2.0
*/
@Nonnull
@CheckReturnValue
RestAction<Void> clearReactionsById(@Nonnull String messageId, @Nonnull String unicode);
/**
* Removes all reactions for the specified emoji.
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account lost access to the channel by either being removed from the guild
* or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>The provided {@link Emote} was deleted or doesn't exist.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The message was deleted.</li>
* </ul>
*
* @param messageId
* The id for the target message
* @param emote
* The {@link Emote} to remove reactions for
*
* @throws InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MESSAGE_MANAGE} in the channel
* @throws IllegalArgumentException
* If provided with null
*
* @return {@link RestAction}
*
* @since 4.2.0
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> clearReactionsById(@Nonnull String messageId, @Nonnull Emote emote)
{
Checks.notNull(emote, "Emote");
return clearReactionsById(messageId, emote.getName() + ":" + emote.getId());
}
/**
* Removes all reactions for the specified emoji.
*
* <h4>Example</h4>
* <pre><code>
* // custom
* channel.clearReactions(messageId, "minn:245267426227388416").queue();
* // unicode escape
* channel.clearReactions(messageId, "\uD83D\uDE02").queue();
* // codepoint notation
* channel.clearReactions(messageId, "U+1F602").queue();
* </code></pre>
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account lost access to the channel by either being removed from the guild
* or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>The provided unicode emoji doesn't exist. Try using one of the example formats.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The message was deleted.</li>
* </ul>
*
* @param messageId
* The id for the target message
* @param unicode
* The unicode emoji to remove reactions for
*
* @throws InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MESSAGE_MANAGE} in the channel
* @throws IllegalArgumentException
* If provided with null
*
* @return {@link RestAction}
*
* @since 4.2.0
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> clearReactionsById(long messageId, @Nonnull String unicode)
{
return clearReactionsById(Long.toUnsignedString(messageId), unicode);
}
/**
* Removes all reactions for the specified emoji.
*
* <p>The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The currently logged in account lost access to the channel by either being removed from the guild
* or losing the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>The provided {@link Emote} was deleted or doesn't exist.</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>The message was deleted.</li>
* </ul>
*
* @param messageId
* The id for the target message
* @param emote
* The {@link Emote} to remove reactions for
*
* @throws InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MESSAGE_MANAGE} in the channel
* @throws IllegalArgumentException
* If provided with null
*
* @return {@link RestAction}
*
* @since 4.2.0
*/
@Nonnull
@CheckReturnValue
default RestAction<Void> clearReactionsById(long messageId, @Nonnull Emote emote)
{
return clearReactionsById(Long.toUnsignedString(messageId), emote);
}
/**
* Send up to 3 stickers in this channel.
* <br>Bots can only send {@link GuildSticker GuildStickers} from the same {@link Guild}.
* Bots cannot use {@link net.dv8tion.jda.api.entities.sticker.StandardSticker StandardStickers}.
*
* @param stickers
* Collection of 1-3 stickers to send
*
* @throws MissingAccessException
* If the currently logged in account does not have {@link Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} in this channel
* @throws InsufficientPermissionException
* <ul>
* <li>If this is a {@link ThreadChannel} and the bot does not have {@link Permission#MESSAGE_SEND_IN_THREADS Permission.MESSAGE_SEND_IN_THREADS}</li>
* <li>If this is not a {@link ThreadChannel} and the bot does not have {@link Permission#MESSAGE_SEND Permission.MESSAGE_SEND}</li>
* </ul>
* @throws IllegalArgumentException
* <ul>
* <li>If any of the provided stickers is a {@link GuildSticker},
* which is either {@link GuildSticker#isAvailable() unavailable} or from a different guild.</li>
* <li>If the list is empty or has more than 3 stickers</li>
* <li>If null is provided</li>
* </ul>
*
* @return {@link MessageAction}
*
* @see Sticker#fromId(long)
*/
@Nonnull
@CheckReturnValue
MessageAction sendStickers(@Nonnull Collection<? extends StickerSnowflake> stickers);
/**
* Send up to 3 stickers in this channel.
* <br>Bots can only send {@link GuildSticker GuildStickers} from the same {@link Guild}.
* Bots cannot use {@link net.dv8tion.jda.api.entities.sticker.StandardSticker StandardStickers}.
*
* @param stickers
* The 1-3 stickers to send
*
* @throws MissingAccessException
* If the currently logged in account does not have {@link Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} in this channel
* @throws InsufficientPermissionException
* <ul>
* <li>If this is a {@link ThreadChannel} and the bot does not have {@link Permission#MESSAGE_SEND_IN_THREADS Permission.MESSAGE_SEND_IN_THREADS}</li>
* <li>If this is not a {@link ThreadChannel} and the bot does not have {@link Permission#MESSAGE_SEND Permission.MESSAGE_SEND}</li>
* </ul>
* @throws IllegalArgumentException
* <ul>
* <li>If any of the provided stickers is a {@link GuildSticker},
* which is either {@link GuildSticker#isAvailable() unavailable} or from a different guild.</li>
* <li>If the list is empty or has more than 3 stickers</li>
* <li>If null is provided</li>
* </ul>
*
* @return {@link MessageAction}
*
* @see Sticker#fromId(long)
*/
@Nonnull
@CheckReturnValue
default MessageAction sendStickers(@Nonnull StickerSnowflake... stickers)
{
Checks.notEmpty(stickers, "Stickers");
return sendStickers(Arrays.asList(stickers));
}
}