Constructor and Description |
---|
JDAImpl() |
JDAImpl(java.lang.String proxyUrl,
int proxyPort) |
Modifier and Type | Method and Description |
---|---|
void |
ack(Message msg)
Acks a specific message.
|
void |
addEventListener(java.lang.Object listener)
Adds an Object to the event-listeners that will be used to handle events.
|
GuildManager |
createGuild(java.lang.String name)
Deprecated.
|
GuildManager |
createGuild(java.lang.String name,
Region region)
Creates a new
Guild . |
void |
createGuildAsync(java.lang.String name,
java.util.function.Consumer<GuildManager> callback)
Deprecated.
|
void |
createGuildAsync(java.lang.String name,
Region region,
java.util.function.Consumer<GuildManager> callback)
Creates a new
Guild . |
AccountManager |
getAccountManager()
Returns the
AccountManager for the currently logged in account.Account settings can only be modified using this object. |
AudioManager |
getAudioManager()
Returns the
AudioManager for this JDA
instance. |
java.lang.String |
getAuthToken()
The login token that is currently being used for Discord authentication.
|
java.util.Map<java.lang.String,TextChannel> |
getChannelMap() |
WebSocketClient |
getClient() |
IEventManager |
getEventManager() |
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.Map<java.lang.String,Guild> |
getGuildMap() |
java.util.List<Guild> |
getGuilds()
|
java.util.List<Guild> |
getGuildsByName(java.lang.String name)
|
java.lang.Long |
getMessageLimit() |
java.util.Map<java.lang.String,java.lang.String> |
getOffline_pms() |
java.util.Map<java.lang.String,PrivateChannel> |
getPmChannelMap() |
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.List<PrivateChannel> |
getPrivateChannels()
An unmodifiable list of all known
PrivateChannels . |
Requester |
getRequester() |
int |
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. |
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.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)
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. |
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.Map<java.lang.String,User> |
getUserMap() |
java.util.List<User> |
getUsers()
|
java.util.List<User> |
getUsersByName(java.lang.String name)
|
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)
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.Map<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. |
boolean |
isAckAllowed() |
boolean |
isDebug()
Used to determine if JDA is currently in debug mode.
|
void |
login(java.lang.String email,
java.lang.String password)
Attempts to login to Discord.
|
void |
removeEventListener(java.lang.Object listener)
Removes the provided Object from the event-listeners and no longer uses it to handle events.
|
void |
setAllowAck(boolean enable)
Enables or disables the ack functionality of JDA.
Read the Javadocs of ack(Message) for guidelines on how and when to ack! |
void |
setAuthToken(java.lang.String token) |
void |
setDebug(boolean enableDebug)
Used to enable JDA debug output.
|
void |
setEventManager(IEventManager manager)
Changes the internal EventManager.
|
void |
setMessageTimeout(long timeout) |
void |
setResponseTotal(int responseTotal) |
void |
setSelfInfo(SelfInfo selfInfo) |
void |
shutdown()
Shuts down JDA, closing all its connections.
|
void |
shutdown(boolean free)
Shuts down JDA, closing all its connections.
|
public JDAImpl()
public JDAImpl(java.lang.String proxyUrl, int proxyPort)
public void login(java.lang.String email, java.lang.String password) throws java.lang.IllegalArgumentException, javax.security.auth.login.LoginException
email
- The email of the account attempting to log in.password
- The password of the account attempting to log in.java.lang.IllegalArgumentException
- Thrown if this email or password provided are empty or null.javax.security.auth.login.LoginException
- Thrown if the email-password combination fails the auth check with the Discord servers.public java.lang.String getAuthToken()
JDA
getAuthToken
in interface JDA
public void setAuthToken(java.lang.String token)
public void setEventManager(IEventManager manager)
JDA
InterfacedEventListener
.
There is also an AnnotatedEventManager
available.setEventManager
in interface JDA
manager
- 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 IEventManager getEventManager()
public WebSocketClient getClient()
public java.util.Map<java.lang.String,User> getUserMap()
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)
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
.Users
that all have the same name as the provided name.public java.util.Map<java.lang.String,Guild> getGuildMap()
public java.util.List<Guild> getGuildsByName(java.lang.String name)
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
.Guilds
that all have the same name as
the provided name.public java.util.List<TextChannel> getTextChannelsByName(java.lang.String name)
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
.TextChannels
that all have the
same name as the provided name.public java.util.List<VoiceChannel> getVoiceChannelByName(java.lang.String name)
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
.VoiceChannels
that all have the
same name as the provided name.public java.util.List<PrivateChannel> getPrivateChannels()
JDA
PrivateChannels
.getPrivateChannels
in interface JDA
PrivateChannels
.@Deprecated public GuildManager createGuild(java.lang.String name)
JDA
JDA.createGuild(String, Region)
.
Creates a new Guild
.
This will a return the Manager to the existing, but still empty Guild (no members, no channels).
To create a Guild asynchronously (wait for generation of #general chat), use JDA.createGuildAsync(String, Consumer)
instead.
In the very rare case, that the Discord-server has problems, The created guild can be unavailable until it is actually created.
In that case, this will return null.createGuild
in interface JDA
name
- the name of the new Guild
GuildManager
for the created Guild, or null, if the created Guild is temporarily unavailablepublic GuildManager createGuild(java.lang.String name, Region region)
JDA
Guild
.
This will a return the Manager to the existing, but still empty Guild (no members, no channels).
To create a Guild asynchronously (wait for generation of #general chat), use JDA.createGuildAsync(String, Consumer)
instead.
In the very rare case, that the Discord-server has problems, The created guild can be unavailable until it is actually created.
In that case, this will return null.createGuild
in interface JDA
name
- the name of the new Guild
region
- the region of the new Guild
GuildManager
for the created Guild, or null, if the created Guild is temporarily unavailable@Deprecated public void createGuildAsync(java.lang.String name, java.util.function.Consumer<GuildManager> callback)
JDA
JDA.createGuildAsync(String, Region, Consumer)
.
Creates a new Guild
.
This function will wait until the Guild was fully created by the Discord-Server (default channels,...),
and then call the provided callback-function with the GuildManager-object
To create a Guild synchronously, use JDA.createGuild(String)
insteadcreateGuildAsync
in interface JDA
name
- the name of the new Guild
callback
- the callback-function that gets called once the guild was fully initializedpublic void createGuildAsync(java.lang.String name, Region region, java.util.function.Consumer<GuildManager> callback)
JDA
Guild
.
This function will wait until the Guild was fully created by the Discord-Server (default channels,...),
and then call the provided callback-function with the GuildManager-object
To create a Guild synchronously, use JDA.createGuild(String)
insteadcreateGuildAsync
in interface JDA
name
- the name of the new Guild
region
- the region of the new Guild
callback
- the callback-function that gets called once the guild was fully initializedpublic 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.Map<java.lang.String,TextChannel> getChannelMap()
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.Map<java.lang.String,VoiceChannel> getVoiceChannelMap()
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 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 java.util.Map<java.lang.String,PrivateChannel> getPmChannelMap()
public java.util.Map<java.lang.String,java.lang.String> getOffline_pms()
public SelfInfo getSelfInfo()
JDA
SelfInfo
.getSelfInfo
in interface JDA
public void setSelfInfo(SelfInfo selfInfo)
public int getResponseTotal()
JDA
getResponseTotal
in interface JDA
public void setResponseTotal(int responseTotal)
public Requester getRequester()
public org.apache.http.HttpHost getGlobalProxy()
JDA
getGlobalProxy
in interface JDA
Proxy.NO_PROXY
is returned.public AccountManager getAccountManager()
JDA
AccountManager
for the currently logged in account.getAccountManager
in interface JDA
public void setDebug(boolean enableDebug)
JDA
public boolean isDebug()
JDA
public void shutdown()
JDA
JDA.shutdown(boolean)
instead.
To reconnect, just create a new JDA instance.public void shutdown(boolean free)
JDA
public void setMessageTimeout(long timeout)
public java.lang.Long getMessageLimit()
public void setAllowAck(boolean enable)
ack(Message)
for guidelines on how and when to ack!enable
- whether or not to enable ack functionalitypublic boolean isAckAllowed()
public void ack(Message msg)
setAllowAck(boolean)
.msg
- the message to ackpublic AudioManager getAudioManager()
JDA
AudioManager
for this JDA
instance. AudioManager deals with creating, managing and severing audio connections to
VoiceChannels
.getAudioManager
in interface JDA