-
-
Notifications
You must be signed in to change notification settings - Fork 722
/
TextChannel.java
600 lines (579 loc) · 31.5 KB
/
TextChannel.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
/*
* Copyright 2015-2018 Austin Keener & Michael Ritter & Florian Spieß
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dv8tion.jda.core.entities;
import net.dv8tion.jda.core.requests.RestAction;
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.core.requests.restaction.WebhookAction;
import net.dv8tion.jda.core.utils.Checks;
import net.dv8tion.jda.core.utils.MiscUtil;
import javax.annotation.CheckReturnValue;
import java.util.Collection;
import java.util.FormattableFlags;
import java.util.Formatter;
import java.util.List;
/**
* Represents a Discord Text Channel. See {@link net.dv8tion.jda.core.entities.Channel Channel} and
* {@link net.dv8tion.jda.core.entities.MessageChannel MessageChannel} for more information.
*
* <p>Internal implementation of this class is available at
* {@link net.dv8tion.jda.core.entities.impl.TextChannelImpl TextChannelImpl}.
* <br>Note: Internal implementation should not be used directly.
*/
public interface TextChannel extends Channel, MessageChannel, Comparable<TextChannel>, IMentionable
{
/**
* The topic set for this TextChannel.
* <br>If no topic has been set, this returns null.
*
* @return Possibly-null String containing the topic of this TextChannel.
*/
String getTopic();
/**
* Whether or not this channel is considered as "NSFW" (Not-Safe-For-Work)
* <br>This will check whether the name of this TextChannel begins with {@code nsfw-} or is equal to {@code nsfw}!
*
* @return True, If this TextChannel is considered NSFW by the official Discord Client
*/
boolean isNSFW();
/**
* The slowmode set for this TextChannel.
* <br>If slowmode is set this returns an {@code int} between 1 and 21600. If not set this returns {@code 0}.
*
* <p>Note that only {@link net.dv8tion.jda.core.AccountType#CLIENT CLIENT} type accounts are
* affected by slowmode, and that {@link net.dv8tion.jda.core.AccountType#BOT BOT} accounts
* are immune to the restrictions.
* <br>Having {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
* {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
* grants immunity to slowmode.
*
* @return The slowmode for this TextChannel, between 1 and 21600, or {@code 0} if no slowmode is set.
*/
int getSlowmode();
/**
* Retrieves the {@link net.dv8tion.jda.core.entities.Webhook Webhooks} attached to this TextChannel.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
* </ul>
*
* @return {@link net.dv8tion.jda.core.requests.RestAction} - Type: List{@literal <}{@link net.dv8tion.jda.core.entities.Webhook Webhook}{@literal >}
* <br>An immutable list of Webhook attached to this channel
*/
@CheckReturnValue
RestAction<List<Webhook>> getWebhooks();
/**
* Creates a new {@link net.dv8tion.jda.core.entities.Webhook Webhook}.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The webhook could not be created due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>We were removed from the Guild before finishing the task</li>
* </ul>
*
* @param name
* The default name for the new Webhook.
*
* @throws net.dv8tion.jda.core.exceptions.PermissionException
* If you do not hold the permission {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS Manage Webhooks}
* @throws IllegalArgumentException
* If the provided name is {@code null}, blank or not
* between 2-100 characters in length
*
* @return A specific {@link net.dv8tion.jda.core.requests.restaction.WebhookAction WebhookAction}
* <br>This action allows to set fields for the new webhook before creating it
*/
@CheckReturnValue
WebhookAction createWebhook(String name);
/**
* Bulk deletes a list of messages.
* <b>This is not the same as calling {@link net.dv8tion.jda.core.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.core.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.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>if any of the provided messages does not exist</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.core.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.core.exceptions.InsufficientPermissionException
* If this account does not have {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @see #deleteMessagesByIds(Collection)
* @see #purgeMessages(List)
*/
@CheckReturnValue
RestAction<Void> deleteMessages(Collection<Message> messages);
/**
* Bulk deletes a list of messages.
* <b>This is not the same as calling {@link net.dv8tion.jda.core.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.core.entities.Message#delete()} method instead.
*
* <br><p>You must have {@link net.dv8tion.jda.core.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.core.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.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE}
* <br>if any of the provided messages does not exist</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.core.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.core.exceptions.InsufficientPermissionException
* If this account does not have {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*
* @see #deleteMessages(Collection)
* @see #purgeMessagesById(List)
*/
@CheckReturnValue
RestAction<Void> deleteMessagesByIds(Collection<String> messageIds);
/**
* Deletes a {@link net.dv8tion.jda.core.entities.Webhook Webhook} attached to this channel
* by the {@code id} specified.
*
* <p>Possible ErrorResponses include:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_WEBHOOK}
* <br>The provided id does not refer to a WebHook present in this TextChannel, either due
* to it not existing or having already been deleted.</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>if this channel was deleted</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>if we were removed from the guild</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The send request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS Permission.MANAGE_WEBHOOKS} in the channel.</li>
* </ul>
*
* @param id
* The not-null id for the target Webhook.
*
* @throws java.lang.IllegalArgumentException
* If the provided {@code id} is {@code null} or empty.
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS Permission.MANAGE_WEBHOOKS} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@CheckReturnValue
AuditableRestAction<Void> deleteWebhookById(String id);
/**
* 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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed.</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The clear-reactions request was attempted after the account lost {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
* in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} when adding the reaction.</li>
*
* <li>{@link net.dv8tion.jda.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.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.core.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@CheckReturnValue
RestAction<Void> clearReactionsById(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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed.</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The clear-reactions request was attempted after the account lost {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE}
* in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} when adding the reaction.</li>
*
* <li>{@link net.dv8tion.jda.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@CheckReturnValue
default RestAction<Void> clearReactionsById(long messageId)
{
return clearReactionsById(Long.toUnsignedString(messageId));
}
/**
* 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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* was revoked in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.core.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.core.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 at
* <a href="http://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">http://unicode.org/emoji/charts/full-emoji-list.html</a></li>
*
* <li>{@link net.dv8tion.jda.core.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.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction}
*/
@CheckReturnValue
RestAction<Void> removeReactionById(String messageId, String unicode, 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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* was revoked in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.core.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.core.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 at
* <a href="http://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">http://unicode.org/emoji/charts/full-emoji-list.html</a></li>
*
* <li>{@link net.dv8tion.jda.core.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.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction}
*/
@CheckReturnValue
default RestAction<Void> removeReactionById(long messageId, String unicode, 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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* was revoked in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.core.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.core.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 at
* <a href="http://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">http://unicode.org/emoji/charts/full-emoji-list.html</a></li>
*
* <li>{@link net.dv8tion.jda.core.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.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction}
*/
@CheckReturnValue
default RestAction<Void> removeReactionById(String messageId, Emote emote, 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.core.requests.ErrorResponse ErrorResponses} are possible:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.core.entities.Guild Guild} or {@link net.dv8tion.jda.client.entities.Group Group}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* was revoked in the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.core.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The request was attempted after the account lost
* {@link net.dv8tion.jda.core.Permission#MESSAGE_ADD_REACTION Permission.MESSAGE_ADD_REACTION} in the
* {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.</li>
*
* <li>{@link net.dv8tion.jda.core.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 at
* <a href="http://unicode.org/emoji/charts/full-emoji-list.html" target="_blank">http://unicode.org/emoji/charts/full-emoji-list.html</a></li>
*
* <li>{@link net.dv8tion.jda.core.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.core.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.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have
* {@link net.dv8tion.jda.core.Permission#MESSAGE_MANAGE Permission.MESSAGE_MANAGE} in this channel.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction}
*/
@CheckReturnValue
default RestAction<Void> removeReactionById(long messageId, Emote emote, User user)
{
return removeReactionById(Long.toUnsignedString(messageId), emote, user);
}
/**
* Whether we can send messages in this channel.
* <br>This is an overload of {@link #canTalk(Member)} with the SelfMember.
* <br>Checks for both {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} and
* {@link net.dv8tion.jda.core.Permission#MESSAGE_WRITE Permission.MESSAGE_WRITE}.
*
* @return True, if we are able to read and send messages in this channel
*/
boolean canTalk();
/**
* Whether the specified {@link net.dv8tion.jda.core.entities.Member}
* can send messages in this channel.
* <br>Checks for both {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} and
* {@link net.dv8tion.jda.core.Permission#MESSAGE_WRITE Permission.MESSAGE_WRITE}.
*
* @param member
* The Member to check
*
* @return True, if the specified member is able to read and send messages in this channel
*/
boolean canTalk(Member member);
@Override
default void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
String out;
if (alt)
out = "#" + (upper ? getName().toUpperCase(formatter.locale()) : getName());
else
out = getAsMention();
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
}