/
JDA.java
813 lines (744 loc) · 37.7 KB
/
JDA.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
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
/*
* Copyright 2015-2017 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;
import net.dv8tion.jda.bot.JDABot;
import net.dv8tion.jda.client.JDAClient;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.hooks.IEventManager;
import net.dv8tion.jda.core.managers.Presence;
import net.dv8tion.jda.core.requests.RestAction;
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction;
import javax.annotation.CheckReturnValue;
import java.util.Collection;
import java.util.List;
/**
* The core of JDA. Acts as a registry system of JDA. All parts of the the API can be accessed starting from this class.
*/
public interface JDA
{
/**
* Represents the connection status of JDA and its Main WebSocket.
*/
enum Status
{
/**JDA is currently setting up supporting systems like the AudioSystem.*/
INITIALIZING,
/**JDA has finished setting up supporting systems and is ready to log in.*/
INITIALIZED,
/**JDA is currently attempting to log in.*/
LOGGING_IN,
/**JDA is currently attempting to connect it's websocket to Discord.*/
CONNECTING_TO_WEBSOCKET,
/**JDA has successfully connected it's websocket to Discord and is populating internal objects.
* This process often takes the longest of all Statuses (besides CONNECTED)*/
LOADING_SUBSYSTEMS,
/**JDA has finished loading everything, is receiving information from Discord and is firing events.*/
CONNECTED,
/**JDA's main websocket has been disconnected. This <b>DOES NOT</b> mean JDA has shutdown permanently.
* This is an in-between status. Most likely ATTEMPTING_TO_RECONNECT or SHUTTING_DOWN/SHUTDOWN will soon follow.*/
DISCONNECTED,
/** JDA session has been added to {@link net.dv8tion.jda.core.requests.SessionReconnectQueue SessionReconnectQueue}
* and is awaiting to be dequeued for reconnecting.*/
RECONNECT_QUEUED,
/**When trying to reconnect to Discord JDA encountered an issue, most likely related to a lack of internet connection,
* and is waiting to try reconnecting again.*/
WAITING_TO_RECONNECT,
/**JDA has been disconnected from Discord and is currently trying to reestablish the connection.*/
ATTEMPTING_TO_RECONNECT,
/**JDA has received a shutdown request or has been disconnected from Discord and reconnect is disabled, thus,
* JDA is in the process of shutting down*/
SHUTTING_DOWN,
/**JDA has finished shutting down and this instance can no longer be used to communicate with the Discord servers.*/
SHUTDOWN,
/**While attempting to authenticate, Discord reported that the provided authentication information was invalid.*/
FAILED_TO_LOGIN,
}
/**
* Represents the information used to create this shard.
*/
class ShardInfo
{
int shardId;
int shardTotal;
ShardInfo(int shardId, int shardTotal)
{
this.shardId = shardId;
this.shardTotal = shardTotal;
}
/**
* Represents the id of the shard of the current instance.
* <br>This value will be between 0 and ({@link #getShardTotal()} - 1).
*
* @return The id of the currently logged in shard.
*/
public int getShardId()
{
return shardId;
}
/**
* The total amount of shards based on the value provided during JDA instance creation using
* {@link JDABuilder#useSharding(int, int)}.
* <br>This <b>does not</b> query Discord to determine the total number of shards.
* <br>This <b>does not</b> represent the amount of logged in shards.
* <br>It strictly represents the integer value provided to discord
* representing the total amount of shards that the developer indicated that it was going to use when
* initially starting JDA.
*
* @return The total of shards based on the total provided by the developer during JDA initialization.
*/
public int getShardTotal()
{
return shardTotal;
}
/**
* Provides a shortcut method for easily printing shard info.
* <br>Format: "[# / #]"
* <br>Where the first # is shardId and the second # is shardTotal.
*
* @return A String representing the information used to build this shard.
*/
public String getShardString()
{
return "[" + shardId + " / " + shardTotal + "]";
}
@Override
public String toString()
{
return "Shard " + getShardString();
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof ShardInfo))
return false;
ShardInfo oInfo = (ShardInfo) o;
return shardId == oInfo.shardId && shardTotal == oInfo.shardTotal;
}
}
/**
* Gets the current {@link net.dv8tion.jda.core.JDA.Status Status} of the JDA instance.
*
* @return Current JDA status.
*/
Status getStatus();
/**
* The time in milliseconds that discord took to respond to our last heartbeat
* <br>This roughly represents the WebSocket ping of this session
*
* <p><b>{@link net.dv8tion.jda.core.requests.RestAction RestAction} request times do not
* correlate to this value!</b>
*
* @return time in milliseconds between heartbeat and the heartbeat ack response
*/
long getPing();
/**
* Contains all {@code cf-ray} headers that JDA received in this session.
* <br>These receive a new value whenever the WebSockedClient reconnects to the gateway.
*
* <p>This is useful to monitor cloudflare activity from the Discord Developer perspective.
* <br>Use this list to report connection issues.
*
* @return Immutable list of all cf-ray values for this session
*/
List<String> getCloudflareRays();
/**
* Receives all valid {@code _trace} lines that have been sent to us
* in this session.
* <br>These values reset on every reconnect! (not resume)
*
* @return List of all websocket traces
*/
List<String> getWebSocketTrace();
/**
* Changes the internal EventManager.
*
* <p>The default EventManager is {@link net.dv8tion.jda.core.hooks.InterfacedEventManager InterfacedEventListener}.
* <br>There is also an {@link net.dv8tion.jda.core.hooks.AnnotatedEventManager AnnotatedEventManager} available.
*
* @param manager
* The new EventManager to use
*/
void setEventManager(IEventManager manager);
/**
* Adds all provided listeners to the event-listeners that will be used to handle events.
* This uses the {@link net.dv8tion.jda.core.hooks.InterfacedEventManager InterfacedEventListener} by default.
* To switch to the {@link net.dv8tion.jda.core.hooks.AnnotatedEventManager AnnotatedEventManager}, use {@link #setEventManager(IEventManager)}.
*
* Note: when using the {@link net.dv8tion.jda.core.hooks.InterfacedEventManager InterfacedEventListener} (default),
* given listener <b>must</b> be instance of {@link net.dv8tion.jda.core.hooks.EventListener EventListener}!
*
* @param listeners
* The listener(s) which will react to events.
*/
void addEventListener(Object... listeners);
/**
* Removes all provided listeners from the event-listeners and no longer uses them to handle events.
*
* @param listeners
* The listener(s) to be removed.
*/
void removeEventListener(Object... listeners);
/**
* Returns an unmodifiable List of Objects that have been registered as EventListeners.
*
* @return List of currently registered Objects acting as EventListeners.
*/
List<Object> getRegisteredListeners();
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.User Users} that share a
* {@link net.dv8tion.jda.core.entities.Guild Guild} with the currently logged in account.
* <br>This list will never contain duplicates and represents all {@link net.dv8tion.jda.core.entities.User Users}
* that JDA can currently see.
*
* <p>If the developer is sharding, then only users from guilds connected to the specifically logged in
* shard will be returned in the List.
*
* @return List of all {@link net.dv8tion.jda.core.entities.User Users} that are visible to JDA.
*/
List<User> getUsers();
/**
* This returns the {@link net.dv8tion.jda.core.entities.User User} which has the same id as the one provided.
* <br>If there is no visible user with an id that matches the provided one, this returns {@code null}.
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.User User}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.User User} with matching id.
*/
User getUserById(String id);
/**
* This returns the {@link net.dv8tion.jda.core.entities.User User} which has the same id as the one provided.
* <br>If there is no visible user with an id that matches the provided one, this returns {@code null}.
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.User User}.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.User User} with matching id.
*/
User getUserById(long id);
/**
* Gets all {@link net.dv8tion.jda.core.entities.Guild Guilds} that contain all given users as their members.
*
* @param users
* The users which all the returned {@link net.dv8tion.jda.core.entities.Guild Guilds} must contain.
*
* @return Unmodifiable list of all {@link net.dv8tion.jda.core.entities.Guild Guild} instances which have all {@link net.dv8tion.jda.core.entities.User Users} in them.
*/
List<Guild> getMutualGuilds(User... users);
/**
* Gets all {@link net.dv8tion.jda.core.entities.Guild Guilds} that contain all given users as their members.
*
* @param users
* The users which all the returned {@link net.dv8tion.jda.core.entities.Guild Guilds} must contain.
*
* @return Unmodifiable list of all {@link net.dv8tion.jda.core.entities.Guild Guild} instances which have all {@link net.dv8tion.jda.core.entities.User Users} in them.
*/
List<Guild> getMutualGuilds(Collection<User> users);
/**
* This unmodifiable returns all {@link net.dv8tion.jda.core.entities.User Users} that have the same username as the one provided.
* <br>If there are no {@link net.dv8tion.jda.core.entities.User Users} with the provided name, then this returns an empty list.
*
* <p><b>Note: </b> This does **not** consider nicknames, it only considers {@link net.dv8tion.jda.core.entities.User#getName()}
*
* @param name
* The name of the requested {@link net.dv8tion.jda.core.entities.User Users}.
* @param ignoreCase
* Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.User#getName()}.
*
* @return Possibly-empty list of {@link net.dv8tion.jda.core.entities.User Users} that all have the same name as the provided name.
*/
List<User> getUsersByName(String name, boolean ignoreCase);
/**
* Attempts to retrieve a {@link net.dv8tion.jda.core.entities.User User} object based on the provided id.
* <br>This first calls {@link #getUserById(long)}, and if the return is {@code null} then a request
* is made to the Discord servers.
*
* <p>The returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} can encounter the following Discord errors:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_USER ErrorResponse.UNKNOWN_USER}
* <br>Occurs when the provided id does not refer to a {@link net.dv8tion.jda.core.entities.User User}
* known by Discord. Typically occurs when developers provide an incomplete id (cut short).</li>
* </ul>
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.User User}.
*
* @throws net.dv8tion.jda.core.exceptions.AccountTypeException
* This endpoint is {@link AccountType#BOT} only.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the provided id String is null.</li>
* <li>If the provided id String is empty.</li>
* </ul>
*
* @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: {@link net.dv8tion.jda.core.entities.User User}
* <br>On request, gets the User with id matching provided id from Discord.
*/
@CheckReturnValue
RestAction<User> retrieveUserById(String id);
/**
* Attempts to retrieve a {@link net.dv8tion.jda.core.entities.User User} object based on the provided id.
* <br>This first calls {@link #getUserById(long)}, and if the return is {@code null} then a request
* is made to the Discord servers.
*
* <p>The returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} can encounter the following Discord errors:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_USER ErrorResponse.UNKNOWN_USER}
* <br>Occurs when the provided id does not refer to a {@link net.dv8tion.jda.core.entities.User User}
* known by Discord. Typically occurs when developers provide an incomplete id (cut short).</li>
* </ul>
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.User User}.
*
* @throws net.dv8tion.jda.core.exceptions.AccountTypeException
* This endpoint is {@link AccountType#BOT} only.
*
* @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: {@link net.dv8tion.jda.core.entities.User User}
* <br>On request, gets the User with id matching provided id from Discord.
*/
@CheckReturnValue
RestAction<User> retrieveUserById(long id);
/**
* An unmodifiable List of all {@link net.dv8tion.jda.core.entities.Guild Guilds} that the logged account is connected to.
* <br>If this account is not connected to any {@link net.dv8tion.jda.core.entities.Guild Guilds}, this will return
* an empty list.
*
* <p>If the developer is sharding ({@link net.dv8tion.jda.core.JDABuilder#useSharding(int, int)},
* then this list will only contain the {@link net.dv8tion.jda.core.entities.Guild Guilds} that the shard is
* actually connected to. Discord determines which guilds a shard is connect to using the following format:
* <br>Guild connected if shardId == (guildId {@literal >>} 22) % totalShards;
* <br>Source for formula: <a href="https://discordapp.com/developers/docs/topics/gateway#sharding">Discord Documentation</a>
*
* @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Guild Guilds} that this account is connected to.
*/
List<Guild> getGuilds();
/**
* This returns the {@link net.dv8tion.jda.core.entities.Guild Guild} which has the same id as the one provided.
* <br>If there is no connected guild with an id that matches the provided one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.Guild Guild}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.Guild Guild} with matching id.
*/
Guild getGuildById(String id);
/**
* This returns the {@link net.dv8tion.jda.core.entities.Guild Guild} which has the same id as the one provided.
* <br>If there is no connected guild with an id that matches the provided one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.Guild Guild}.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.Guild Guild} with matching id.
*/
Guild getGuildById(long id);
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.Guild Guilds} that have the same name as the one provided.
* <br>If there are no {@link net.dv8tion.jda.core.entities.Guild Guilds} with the provided name, then this returns an empty list.
*
* @param name
* The name of the requested {@link net.dv8tion.jda.core.entities.Guild Guilds}.
* @param ignoreCase
* Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.Guild#getName()}.
* @return
* Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Guild Guilds} that all have the same name as
* the provided name.
*/
List<Guild> getGuildsByName(String name, boolean ignoreCase);
/**
* All {@link net.dv8tion.jda.core.entities.Role Roles} this JDA instance can see.
* <br>This will iterate over each {@link net.dv8tion.jda.core.entities.Guild Guild} retrieved from
* {@link #getGuilds()} and collect its {@link net.dv8tion.jda.core.entities.Guild#getRoles() Guild.getRoles()}.
*
* @return Immutable List of all visible Roles
*/
List<Role> getRoles();
/**
* Retrieves the {@link net.dv8tion.jda.core.entities.Role Role} associated to the provided id.
* <br>This iterates over all {@link net.dv8tion.jda.core.entities.Guild Guilds} and check whether
* a Role from that Guild is assigned to the specified ID and will return the first that can be found.
*
* @param id
* The id of the searched Role
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.Role Role} for the specified ID
*/
Role getRoleById(String id);
/**
* Retrieves the {@link net.dv8tion.jda.core.entities.Role Role} associated to the provided id.
* <br>This iterates over all {@link net.dv8tion.jda.core.entities.Guild Guilds} and check whether
* a Role from that Guild is assigned to the specified ID and will return the first that can be found.
* @param id
* The id of the searched Role
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.Role Role} for the specified ID
*/
Role getRoleById(long id);
/**
* Retrieves all {@link net.dv8tion.jda.core.entities.Role Roles} visible to this JDA instance.
* <br>This simply filters the Roles returned by {@link #getRoles()} with the provided name, either using
* {@link String#equals(Object)} or {@link String#equalsIgnoreCase(String)} on {@link net.dv8tion.jda.core.entities.Role#getName()}.
*
* @param name
* The name for the Roles
* @param ignoreCase
* Whether to use {@link String#equalsIgnoreCase(String)}
*
* @return Immutable List of all Roles matching the parameters provided.
*/
List<Role> getRolesByName(String name, boolean ignoreCase);
//TODO docs
Category getCategoryById(String id);
Category getCategoryById(long id);
List<Category> getCategories();
List<Category> getCategoriesByName(String name, boolean ignoreCase);
/**
* An unmodifiable List of all {@link net.dv8tion.jda.core.entities.TextChannel TextChannels} of all connected
* {@link net.dv8tion.jda.core.entities.Guild Guilds}.
*
* <p><b>Note:</b> just because a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} is present in this list does
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is possible that you will see fewer channels than this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
*
* @return Possibly-empty list of all known {@link net.dv8tion.jda.core.entities.TextChannel TextChannels}.
*/
List<TextChannel> getTextChannels();
/**
* This returns the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p><b>Note:</b> just because a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} is present does
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is you will not see the channel that this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} with matching id.
*/
TextChannel getTextChannelById(String id);
/**
* This returns the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p><b>Note:</b> just because a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} is present does
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is you will not see the channel that this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} with matching id.
*/
TextChannel getTextChannelById(long id);
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.TextChannel TextChannels} that have the same name as the one provided.
* <br>If there are no {@link net.dv8tion.jda.core.entities.TextChannel TextChannels} with the provided name, then this returns an empty list.
*
* <p><b>Note:</b> just because a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} is present in this list does
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is possible that you will see fewer channels than this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.core.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
*
* @param name
* The name of the requested {@link net.dv8tion.jda.core.entities.TextChannel TextChannels}.
* @param ignoreCase
* Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.TextChannel#getName()}.
*
* @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.TextChannel TextChannels} that all have the
* same name as the provided name.
*/
List<TextChannel> getTextChannelsByName(String name, boolean ignoreCase);
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels} of all connected
* {@link net.dv8tion.jda.core.entities.Guild Guilds}.
*
* @return Possible-empty list of all known {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels}.
*/
List<VoiceChannel> getVoiceChannels();
/**
* This returns the {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* @param id The id of the {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} with matching id.
*/
VoiceChannel getVoiceChannelById(String id);
/**
* This returns the {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* @param id The id of the {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel}.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannel} with matching id.
*/
VoiceChannel getVoiceChannelById(long id);
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels} that have the same name as the one provided.
* <br>If there are no {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels} with the provided name, then this returns an empty list.
*
* @param name
* The name of the requested {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels}.
* @param ignoreCase
* Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.VoiceChannel#getName()}.
*
* @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.VoiceChannel VoiceChannels} that all have the
* same name as the provided name.
*/
List<VoiceChannel> getVoiceChannelByName(String name, boolean ignoreCase);
/**
* An unmodifiable list of all known {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannels}.
*
* @return Possibly-empty list of all {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannels}.
*/
List<PrivateChannel> getPrivateChannels();
/**
* This returns the {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} with an id that matches the
* provided one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} with matching id.
*/
PrivateChannel getPrivateChannelById(String id);
/**
* This returns the {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} with an id that matches the
* provided one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel}.
*
* @return Possibly-null {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} with matching id.
*/
PrivateChannel getPrivateChannelById(long id);
/**
* A collection of all to us known emotes (managed/restricted included).
*
* <p><b>Hint</b>: To check whether you can use an {@link net.dv8tion.jda.core.entities.Emote Emote} in a specific
* context you can use {@link Emote#canInteract(net.dv8tion.jda.core.entities.Member)} or
* {@link Emote#canInteract(net.dv8tion.jda.core.entities.User, net.dv8tion.jda.core.entities.MessageChannel)}
*
* <p><b>Unicode emojis are not included as {@link net.dv8tion.jda.core.entities.Emote Emote}!</b>
*
* @return An immutable list of Emotes (which may or may not be available to usage).
*/
List<Emote> getEmotes();
/**
* Retrieves an emote matching the specified {@code id} if one is available in our cache.
*
* <p><b>Unicode emojis are not included as {@link net.dv8tion.jda.core.entities.Emote Emote}!</b>
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.Emote}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return An {@link net.dv8tion.jda.core.entities.Emote Emote} represented by this id or null if none is found in our cache.
*/
Emote getEmoteById(String id);
/**
* Retrieves an emote matching the specified {@code id} if one is available in our cache.
*
* <p><b>Unicode emojis are not included as {@link net.dv8tion.jda.core.entities.Emote Emote}!</b>
*
* @param id
* The id of the requested {@link net.dv8tion.jda.core.entities.Emote}.
*
* @return An {@link net.dv8tion.jda.core.entities.Emote Emote} represented by this id or null if none is found in our cache.
*/
Emote getEmoteById(long id);
/**
* An unmodifiable list of all {@link net.dv8tion.jda.core.entities.Emote Emotes} that have the same name as the one provided.
* <br>If there are no {@link net.dv8tion.jda.core.entities.Emote Emotes} with the provided name, then this returns an empty list.
*
* <p><b>Unicode emojis are not included as {@link net.dv8tion.jda.core.entities.Emote Emote}!</b>
*
* @param name
* The name of the requested {@link net.dv8tion.jda.core.entities.Emote Emotes}.
* @param ignoreCase
* Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.Emote#getName()}.
*
* @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Emote Emotes} that all have the
* same name as the provided name.
*/
List<Emote> getEmotesByName(String name, boolean ignoreCase);
/**
* Returns the currently logged in account represented by {@link net.dv8tion.jda.core.entities.SelfUser SelfUser}.
* <br>Account settings <b>cannot</b> be modified using this object. If you wish to modify account settings please
* use the AccountManager which is accessible by {@link net.dv8tion.jda.core.entities.SelfUser#getManager()} or
* {@link net.dv8tion.jda.core.entities.SelfUser#getManagerUpdatable()}.
*
* @return The currently logged in account.
*/
SelfUser getSelfUser();
/**
* The {@link net.dv8tion.jda.core.managers.Presence Presence} controller for the current session.
* <br>Used to set {@link net.dv8tion.jda.core.entities.Game} and {@link net.dv8tion.jda.core.OnlineStatus} information.
*
* @return The never-null {@link net.dv8tion.jda.core.managers.Presence Presence} for this session.
*/
Presence getPresence();
/**
* The shard information used when creating this instance of JDA.
* <br>Represents the information provided to {@link net.dv8tion.jda.core.JDABuilder#useSharding(int, int)}.
*
* @return The shard information for this shard or {@code null} if this JDA instance isn't sharding.
*/
ShardInfo getShardInfo();
/**
* The login token that is currently being used for Discord authentication.
*
* @return Never-null, 18 character length string containing the auth token.
*/
String getToken();
/**
* This value is the total amount of JSON responses that discord has sent.
* <br>This value resets every time the websocket has to perform a full reconnect (not resume).
*
* @return Never-negative long containing total response amount.
*/
long getResponseTotal();
/**
* This value is the maximum amount of time, in seconds, that JDA will wait between reconnect attempts.
* <br>Can be set using {@link net.dv8tion.jda.core.JDABuilder#setMaxReconnectDelay(int) JDABuilder.setMaxReconnectDelay(int)}.
*
* @return The maximum amount of time JDA will wait between reconnect attempts in seconds.
*/
int getMaxReconnectDelay();
/**
* Sets whether or not JDA should try to automatically reconnect if a connection-error is encountered.
* <br>This will use an incremental reconnect (timeouts are increased each time an attempt fails).
*
* <p>Default is <b>true</b>.
*
* @param reconnect If true - enables autoReconnect
*/
void setAutoReconnect(boolean reconnect);
/**
* USed to determine whether or not autoReconnect is enabled for JDA.
*
* @return True if JDA will attempt to automatically reconnect when a connection-error is encountered.
*/
boolean isAutoReconnect();
/**
* Used to determine whether the instance of JDA supports audio and has it enabled.
*
* @return True if JDA can currently utilize the audio system.
*/
boolean isAudioEnabled();
/**
* Used to determine if JDA will process MESSAGE_DELETE_BULK messages received from Discord as a single
* {@link net.dv8tion.jda.core.events.message.MessageBulkDeleteEvent MessageBulkDeleteEvent} or split
* the deleted messages up and fire multiple {@link net.dv8tion.jda.core.events.message.MessageDeleteEvent MessageDeleteEvents},
* one for each deleted message.
*
* <p>By default, JDA will separate the bulk delete event into individual delete events, but this isn't as efficient as
* handling a single event would be. It is recommended that BulkDelete Splitting be disabled and that the developer
* should instead handle the {@link net.dv8tion.jda.core.events.message.MessageBulkDeleteEvent MessageBulkDeleteEvent}
*
* @return Whether or not JDA currently handles the BULK_MESSAGE_DELETE event by splitting it into individual MessageDeleteEvents or not.
*/
boolean isBulkDeleteSplittingEnabled();
/**
* Shuts down this JDA instance, closing all its connections.
* After this command is issued the JDA Instance can not be used anymore.
* Already enqueued {@link net.dv8tion.jda.core.requests.RestAction RestActions} are still going to be executed.
*
* <p>If you want this instance to shutdown without executing, use {@link #shutdownNow() shutdownNow()}
*
* @see #shutdownNow()
*/
void shutdown();
/**
* Shuts down this JDA instance instantly.
* This will also cancel all queued {@link net.dv8tion.jda.core.requests.RestAction RestActions}.
*
* @see #shutdown()
*/
void shutdownNow();
/**
* Installs an auxiliary cable into the given port of your system.
*
* @param port
* The port in which the cable should be installed.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}{@literal <}{@link Void}{@literal >}
*/
AuditableRestAction<Void> installAuxiliaryCable(int port);
/**
* The {@link net.dv8tion.jda.core.AccountType} of the currently logged in account.
* <br>Used when determining functions that are restricted based on the type of account.
*
* @return The current AccountType.
*/
AccountType getAccountType();
/**
* Used to access Client specific functions like Groups, Calls, and Friends.
*
* @throws net.dv8tion.jda.core.exceptions.AccountTypeException
* Thrown if the currently logged in account is {@link net.dv8tion.jda.core.AccountType#BOT}
*
* @return The {@link net.dv8tion.jda.client.JDAClient} registry for this instance of JDA.
*/
JDAClient asClient();
/**
* Used to access Bot specific functions like OAuth information.
*
* @throws net.dv8tion.jda.core.exceptions.AccountTypeException
* Thrown if the currently logged in account is {@link net.dv8tion.jda.core.AccountType#CLIENT}
*
* @return The {@link net.dv8tion.jda.bot.JDABot} registry for this instance of JDA.
*/
JDABot asBot();
}