JDA.ShardInfo, JDA.Status
Modifier and Type | Field and Description |
---|---|
protected AccountType |
accountType |
protected boolean |
audioEnabled |
protected boolean |
autoReconnect |
protected boolean |
bulkDeleteSplittingEnabled |
protected WebSocketClient |
client |
protected IEventManager |
eventManager |
protected java.util.HashMap<java.lang.String,PrivateChannel> |
fakePrivateChannels |
protected java.util.HashMap<java.lang.String,User> |
fakeUsers |
protected java.util.HashMap<java.lang.String,Guild> |
guilds |
protected JDABot |
jdaBot |
protected JDAClient |
jdaClient |
static SimpleLog |
LOG |
protected java.util.HashMap<java.lang.String,PrivateChannel> |
privateChannels |
protected org.apache.http.HttpHost |
proxy |
protected Requester |
requester |
protected long |
responseTotal |
protected SelfInfo |
selfInfo |
protected JDA.ShardInfo |
shardInfo |
protected JDA.Status |
status |
protected java.util.HashMap<java.lang.String,TextChannel> |
textChannels |
protected java.lang.String |
token |
protected java.util.HashMap<java.lang.String,User> |
users |
protected boolean |
useShutdownHook |
protected java.util.HashMap<java.lang.String,VoiceChannel> |
voiceChannels |
Constructor and Description |
---|
JDAImpl(AccountType accountType,
org.apache.http.HttpHost proxy,
boolean autoReconnect,
boolean audioEnabled,
boolean useShutdownHook,
boolean bulkDeleteSplittingEnabled) |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(java.lang.Object listener)
Adds an Object to the event-listeners that will be used to handle events.
|
JDABot |
asBot() |
JDAClient |
asClient() |
AccountType |
getAccountType() |
WebSocketClient |
getClient() |
IEventManager |
getEventManager() |
java.util.HashMap<java.lang.String,PrivateChannel> |
getFakePrivateChannelMap() |
java.util.HashMap<java.lang.String,User> |
getFakeUserMap() |
org.apache.http.HttpHost |
getGlobalProxy()
The proxy settings used by all JDA instances.
|
Guild |
getGuildById(java.lang.String id)
This returns the
Guild which has the same id as the one provided.If there is no known guild with an id that matches the provided one, then this returns null . |
java.util.HashMap<java.lang.String,Guild> |
getGuildMap() |
java.util.List<Guild> |
getGuilds()
|
java.util.List<Guild> |
getGuildsByName(java.lang.String name,
boolean ignoreCase)
|
PrivateChannel |
getPrivateChannelById(java.lang.String id)
This returns the
PrivateChannel which has the same id as the one provided.If there is no known PrivateChannel with an id that matches the
provided one, then this returns null . |
java.util.HashMap<java.lang.String,PrivateChannel> |
getPrivateChannelMap() |
java.util.List<PrivateChannel> |
getPrivateChannels()
An unmodifiable list of all known
PrivateChannels . |
java.util.List<java.lang.Object> |
getRegisteredListeners()
Returns an unmodifiable List of Objects that have been registered as EventListeners.
|
Requester |
getRequester() |
long |
getResponseTotal()
This value is the total amount of JSON responses that discord has sent.
This value resets every time the websocket has to reconnect. |
SelfInfo |
getSelfInfo()
Returns the currently logged in account represented by
SelfInfo .Account settings cannot be modified using this object. |
JDA.ShardInfo |
getShardInfo() |
JDA.Status |
getStatus()
Gets the current
Status of the JDA instance. |
TextChannel |
getTextChannelById(java.lang.String id)
This returns the
TextChannel which has the same id as the one provided.If there is no known TextChannel with an id that matches the provided
one, then this returns null . |
java.util.HashMap<java.lang.String,TextChannel> |
getTextChannelMap() |
java.util.List<TextChannel> |
getTextChannels()
An unmodifiable list of all
TextChannels of all Guilds
that this account is a member of. |
java.util.List<TextChannel> |
getTextChannelsByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
TextChannels that have the same name as the one provided.If there are no TextChannels with the provided name, then this returns an empty list. |
java.lang.String |
getToken()
The login token that is currently being used for Discord authentication.
|
User |
getUserById(java.lang.String id)
This returns the
User who has the same id as the one provided.If there is no known user with an id that matches the provided one, this this returns null . |
java.util.HashMap<java.lang.String,User> |
getUserMap() |
java.util.List<User> |
getUsers()
|
java.util.List<User> |
getUsersByName(java.lang.String name,
boolean ignoreCase)
|
VoiceChannel |
getVoiceChannelById(java.lang.String id)
This returns the
VoiceChannel which has the same id as the one provided.If there is no known VoiceChannel with an id that matches the provided
one, then this returns null . |
java.util.List<VoiceChannel> |
getVoiceChannelByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
VoiceChannels that have the same name as the one provided.If there are no VoiceChannels with the provided name, then this returns an empty list. |
java.util.HashMap<java.lang.String,VoiceChannel> |
getVoiceChannelMap() |
java.util.List<VoiceChannel> |
getVoiceChannels()
An unmodifiable list of all
VoiceChannels of all Guilds
that this account is a member of. |
void |
installAuxiliaryCable(int port)
Installs an auxiliary cable into your system.
|
boolean |
isAudioEnabled()
Used to determine whether the instance of JDA supports audio and has it enabled.
|
boolean |
isAutoReconnect()
Returns whether or not autoReconnect is enabled for JDA.
|
boolean |
isBulkDeleteSplittingEnabled()
Used to determine if JDA will process MESSAGE_DELETE_BULK messages received from Discord as a single
MessageBulkDeleteEvent or split
the deleted messages up and fire multiple MessageDeleteEvents ,
one for each deleted message. |
void |
login(java.lang.String token,
JDA.ShardInfo shardInfo) |
void |
removeEventListener(java.lang.Object listener)
Removes the provided Object from the event-listeners and no longer uses it to handle events.
|
void |
setAutoReconnect(boolean autoReconnect)
Sets whether or not JDA should try to reconnect, if a connection-error occured.
|
void |
setEventManager(IEventManager eventManager)
Changes the internal EventManager.
|
void |
setResponseTotal(int responseTotal) |
void |
setSelfInfo(SelfInfo selfInfo) |
void |
setStatus(JDA.Status status) |
void |
setToken(java.lang.String token) |
void |
shutdown()
Shuts down JDA, closing all its connections.
|
void |
shutdown(boolean free)
Shuts down JDA, closing all its connections.
|
java.util.List<IBucket> |
shutdownNow(boolean free) |
void |
verifyToken() |
public static final SimpleLog LOG
protected final java.util.HashMap<java.lang.String,User> users
protected final java.util.HashMap<java.lang.String,Guild> guilds
protected final java.util.HashMap<java.lang.String,TextChannel> textChannels
protected final java.util.HashMap<java.lang.String,VoiceChannel> voiceChannels
protected final java.util.HashMap<java.lang.String,PrivateChannel> privateChannels
protected final java.util.HashMap<java.lang.String,User> fakeUsers
protected final java.util.HashMap<java.lang.String,PrivateChannel> fakePrivateChannels
protected final AccountType accountType
protected final JDAClient jdaClient
protected final JDABot jdaBot
protected org.apache.http.HttpHost proxy
protected WebSocketClient client
protected Requester requester
protected IEventManager eventManager
protected JDA.Status status
protected SelfInfo selfInfo
protected JDA.ShardInfo shardInfo
protected java.lang.String token
protected boolean audioEnabled
protected boolean useShutdownHook
protected boolean bulkDeleteSplittingEnabled
protected boolean autoReconnect
protected long responseTotal
public JDAImpl(AccountType accountType, org.apache.http.HttpHost proxy, boolean autoReconnect, boolean audioEnabled, boolean useShutdownHook, boolean bulkDeleteSplittingEnabled)
public void login(java.lang.String token, JDA.ShardInfo shardInfo) throws javax.security.auth.login.LoginException, RateLimitedException
javax.security.auth.login.LoginException
RateLimitedException
public void setStatus(JDA.Status status)
public void setToken(java.lang.String token)
public void verifyToken() throws javax.security.auth.login.LoginException, RateLimitedException
javax.security.auth.login.LoginException
RateLimitedException
public java.lang.String getToken()
JDA
public org.apache.http.HttpHost getGlobalProxy()
JDA
getGlobalProxy
in interface JDA
Proxy.NO_PROXY
is returned.public boolean isAudioEnabled()
JDA
isAudioEnabled
in interface JDA
public boolean isBulkDeleteSplittingEnabled()
JDA
MessageBulkDeleteEvent
or split
the deleted messages up and fire multiple MessageDeleteEvents
,
one for each deleted message.
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 MessageBulkDeleteEvent
isBulkDeleteSplittingEnabled
in interface JDA
public void setAutoReconnect(boolean autoReconnect)
JDA
setAutoReconnect
in interface JDA
autoReconnect
- If true - enables autoReconnectpublic boolean isAutoReconnect()
JDA
isAutoReconnect
in interface JDA
public JDA.Status getStatus()
JDA
Status
of the JDA instance.public User getUserById(java.lang.String id)
JDA
User
who has the same id as the one provided.null
.getUserById
in interface JDA
id
- The id of the User
.User
with matching id.public java.util.List<User> getUsersByName(java.lang.String name, boolean ignoreCase)
JDA
Users
that have the same username as the one provided.Users
with the provided name, then this returns an empty list.getUsersByName
in interface JDA
name
- The name of the requested Users
.ignoreCase
- Whether to ignore case or not.Users
that all have the same name as the provided name.public Guild getGuildById(java.lang.String id)
JDA
Guild
which has the same id as the one provided.null
.getGuildById
in interface JDA
id
- The id of the Guild
.Guild
with matching id.public java.util.List<Guild> getGuildsByName(java.lang.String name, boolean ignoreCase)
JDA
Guilds
that have the same name as the one provided.Guilds
with the provided name, then this returns an empty list.getGuildsByName
in interface JDA
name
- The name of the requested Guilds
.ignoreCase
- Whether to ignore case or not.Guilds
that all have the same name as
the provided name.public java.util.List<TextChannel> getTextChannels()
JDA
TextChannels
of all Guilds
that this account is a member of.
Note: just because a 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 TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
getTextChannels
in interface JDA
TextChannels
.public TextChannel getTextChannelById(java.lang.String id)
JDA
TextChannel
which has the same id as the one provided.TextChannel
with an id that matches the provided
one, then this returns null
.
Note: just because a 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 TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
getTextChannelById
in interface JDA
id
- The id of the TextChannel
.TextChannel
with matching id.public java.util.List<TextChannel> getTextChannelsByName(java.lang.String name, boolean ignoreCase)
JDA
TextChannels
that have the same name as the one provided.TextChannels
with the provided name, then this returns an empty list.
Note: just because a 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 TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
getTextChannelsByName
in interface JDA
name
- The name of the requested TextChannels
.ignoreCase
- Whether to ignore case or not.TextChannels
that all have the
same name as the provided name.public java.util.List<VoiceChannel> getVoiceChannels()
JDA
VoiceChannels
of all Guilds
that this account is a member of.getVoiceChannels
in interface JDA
VoiceChannels
.public VoiceChannel getVoiceChannelById(java.lang.String id)
JDA
VoiceChannel
which has the same id as the one provided.VoiceChannel
with an id that matches the provided
one, then this returns null
.getVoiceChannelById
in interface JDA
id
- The id of the VoiceChannel
.VoiceChannel
with matching id.public java.util.List<VoiceChannel> getVoiceChannelByName(java.lang.String name, boolean ignoreCase)
JDA
VoiceChannels
that have the same name as the one provided.VoiceChannels
with the provided name, then this returns an empty list.getVoiceChannelByName
in interface JDA
name
- The name of the requested VoiceChannels
.ignoreCase
- Whether to ignore case or not.VoiceChannels
that all have the
same name as the provided name.public java.util.List<PrivateChannel> getPrivateChannels()
JDA
PrivateChannels
.getPrivateChannels
in interface JDA
PrivateChannels
.public PrivateChannel getPrivateChannelById(java.lang.String id)
JDA
PrivateChannel
which has the same id as the one provided.PrivateChannel
with an id that matches the
provided one, then this returns null
.getPrivateChannelById
in interface JDA
id
- The id of the PrivateChannel
.PrivateChannel
with matching id.public SelfInfo getSelfInfo()
JDA
SelfInfo
.getSelfInfo
in interface JDA
public void shutdown()
JDA
JDA.shutdown(boolean)
instead.
To reconnect, just create a new JDA instance.public void shutdown(boolean free)
JDA
public java.util.List<IBucket> shutdownNow(boolean free)
shutdownNow
in interface JDA
public long getResponseTotal()
JDA
getResponseTotal
in interface JDA
public JDA.ShardInfo getShardInfo()
getShardInfo
in interface JDA
public void installAuxiliaryCable(int port) throws java.lang.UnsupportedOperationException
JDA
installAuxiliaryCable
in interface JDA
port
- the portjava.lang.UnsupportedOperationException
public AccountType getAccountType()
getAccountType
in interface JDA
public void setEventManager(IEventManager eventManager)
JDA
InterfacedEventListener
.
There is also an AnnotatedEventManager
available.setEventManager
in interface JDA
eventManager
- The new EventManager to usepublic void addEventListener(java.lang.Object listener)
JDA
InterfacedEventListener
by default.
To switch to the AnnotatedEventManager
, use JDA.setEventManager(IEventManager)
.
Note: when using the InterfacedEventListener
(default),
given listener must be instance of EventListener
!addEventListener
in interface JDA
listener
- The listenerpublic void removeEventListener(java.lang.Object listener)
JDA
removeEventListener
in interface JDA
listener
- The listener to be removed.public java.util.List<java.lang.Object> getRegisteredListeners()
JDA
getRegisteredListeners
in interface JDA
public Requester getRequester()
public IEventManager getEventManager()
public WebSocketClient getClient()
public java.util.HashMap<java.lang.String,User> getUserMap()
public java.util.HashMap<java.lang.String,Guild> getGuildMap()
public java.util.HashMap<java.lang.String,TextChannel> getTextChannelMap()
public java.util.HashMap<java.lang.String,VoiceChannel> getVoiceChannelMap()
public java.util.HashMap<java.lang.String,PrivateChannel> getPrivateChannelMap()
public java.util.HashMap<java.lang.String,User> getFakeUserMap()
public java.util.HashMap<java.lang.String,PrivateChannel> getFakePrivateChannelMap()
public void setSelfInfo(SelfInfo selfInfo)
public void setResponseTotal(int responseTotal)