Class CommandEvent
MessageReceivedEvent
,
CommandClient
, and String user arguments
compatible with all Command
s.
From here, developers can invoke several useful and specialized methods to assist in Command function and development. There are also "extension" methods for all methods found in MessageReceivedEvent.
Methods with "reply" in their name can be used to instantly send a Message
response to the MessageChannel
the MessageReceivedEvent was in.
All RestAction
returned by sending a response using these
methods automatically RestAction#queue()
, and no further developer
input is required.
- Author:
- John Grosh (jagrosh)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCommandEvent
(net.dv8tion.jda.api.events.message.MessageReceivedEvent event, String prefix, String args, CommandClient client) Constructor for a CommandEvent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Uses theclient's executor
to run the providedRunnable
asynchronously without blocking the thread this is called in.getArgs()
Returns the user's String arguments for the command.net.dv8tion.jda.api.entities.User
Gets theUser
who triggered this CommandEvent.net.dv8tion.jda.api.entities.channel.middleman.MessageChannel
Gets theMessageChannel
that the CommandEvent was triggered on.net.dv8tion.jda.api.entities.channel.ChannelType
Gets theChannelType
of theMessageChannel
that the CommandEvent was triggered on.Returns theCommandClient
that initiated this CommandEvent.net.dv8tion.jda.api.events.message.MessageReceivedEvent
getEvent()
Returns the underlyingMessageReceivedEvent
for this CommandEvent.net.dv8tion.jda.api.entities.Guild
getGuild()
Gets theGuild
that this CommandEvent was triggered on.net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel
Gets theGuildMessageChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a GuildMessageChannel.net.dv8tion.jda.api.JDA
getJDA()
Gets the instance ofJDA
that this CommandEvent was caught by.net.dv8tion.jda.api.entities.Member
Gets theMember
that triggered this CommandEvent.net.dv8tion.jda.api.entities.Message
Gets theMessage
responsible for triggering this CommandEvent.Returns the prefix used when this event was raised.net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel
Gets thePrivateChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a PrivateChannel.long
Gets the response number for theMessageReceivedEvent
.net.dv8tion.jda.api.entities.Member
Gets aMember
representing the bot, or null if the event does not take place on aGuild
.net.dv8tion.jda.api.entities.SelfUser
Gets aSelfUser
representing the bot.net.dv8tion.jda.api.entities.channel.concrete.TextChannel
Gets theTextChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a TextChannel.boolean
isFromType
(net.dv8tion.jda.api.entities.channel.ChannelType channelType) Compares a providedChannelType
with the one this CommandEvent occurred on, returningtrue
if they are the same ChannelType.boolean
isOwner()
Tests whether or not theUser
who triggered this event is an owner of the bot.void
linkId
(net.dv8tion.jda.api.entities.Message message) Links aMessage
with the calling Message contained by this CommandEvent.void
Adds an error reaction to the callingMessage
.void
Adds a success reaction to the callingMessage
.void
Adds a warning reaction to the callingMessage
.void
Replies with aFile
with the provided name, or a default name if left null.void
Replies with a String message.void
Replies with a String message and aFile
with the provided name, or a default name if left null.void
Replies with a String message and then queues aConsumer
.void
reply
(String message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with a String message and then queues aConsumer
.void
reply
(net.dv8tion.jda.api.entities.MessageEmbed embed) Replies with aMessageEmbed
.void
reply
(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessageEmbed
and then queues aConsumer
.void
reply
(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessageEmbed
and then queues aConsumer
.void
reply
(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
.void
reply
(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessage
and then queues aConsumer
.void
reply
(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessage
and then queues aConsumer
.void
replyError
(String message) Replies with a String message and a prefixed error emoji.void
replyError
(String message, Consumer<net.dv8tion.jda.api.entities.Message> queue) Replies with a String message and a prefixed error emoji and then queues aConsumer
.void
replyFormatted
(String format, Object... args) Replies with a formatted String message using the provided arguments.void
Replies with a String message sent to the callingUser
'sPrivateChannel
.void
Replies with a String message and aFile
with the provided name, or a default name if left null, and sent to the callingUser
'sPrivateChannel
.void
Replies with a String message sent to the callingUser
'sPrivateChannel
.void
replyInDm
(String message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with a String message sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.entities.MessageEmbed embed) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.entities.Message message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.void
replyInDm
(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.void
replyOrAlternate
(String message, File file, String filename, String alternateMessage) Replies with a String message and aFile
with the provided name, or a default name if left null.void
replyOrAlternate
(net.dv8tion.jda.api.entities.MessageEmbed embed, String alternateMessage) Replies with aMessageEmbed
if possible, or just a String message if it cannot send the embed.void
replySuccess
(String message) Replies with a String message, and a prefixed success emoji.void
replySuccess
(String message, Consumer<net.dv8tion.jda.api.entities.Message> queue) Replies with a String message and a prefixed success emoji and then queues aConsumer
.void
replyWarning
(String message) Replies with a String message, and a prefixed warning emoji.void
replyWarning
(String message, Consumer<net.dv8tion.jda.api.entities.Message> queue) Replies with a String message and a prefixed warning emoji and then queues aConsumer
.splitMessage
(String stringtoSend) Splits a String into one or more Strings who's length does not exceed 2000 characters.
-
Field Details
-
MAX_MESSAGES
public static int MAX_MESSAGES
-
-
Constructor Details
-
CommandEvent
public CommandEvent(net.dv8tion.jda.api.events.message.MessageReceivedEvent event, String prefix, String args, CommandClient client) Constructor for a CommandEvent.You should not call this!
It is a generated wrapper for aMessageReceivedEvent
.- Parameters:
event
- The initial MessageReceivedEventprefix
- The prefix used to execute this commandargs
- The String arguments after the command callclient
- TheCommandClient
-
-
Method Details
-
getArgs
Returns the user's String arguments for the command.
If no arguments have been supplied, then this will return an empty String.- Returns:
- Never-null arguments that a user has supplied to a command
-
getPrefix
Returns the prefix used when this event was raised. Useful for figuring out what people invoked.- Returns:
- Never null prefix used to raise event
-
getEvent
public net.dv8tion.jda.api.events.message.MessageReceivedEvent getEvent()Returns the underlyingMessageReceivedEvent
for this CommandEvent.- Returns:
- The underlying MessageReceivedEvent
-
getClient
Returns theCommandClient
that initiated this CommandEvent.- Returns:
- The initiating CommandClient
-
linkId
public void linkId(net.dv8tion.jda.api.entities.Message message) Links aMessage
with the calling Message contained by this CommandEvent.This method is exposed for those who wish to use linked deletion but may require usage of
MessageChannel#sendMessage()
or for other reasons cannot use the standardreply()
methods.If the Message provided is not from the bot (IE:
SelfUser
), anIllegalArgumentException
will be thrown.- Parameters:
message
- The Message to add, must be from the SelfUser while linked deletion is being used.- Throws:
IllegalArgumentException
- If the Message provided is not from the bot.
-
reply
Replies with a String message.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply with
-
reply
Replies with a String message and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
The Consumer will be applied to the last message sent if this occurs.- Parameters:
message
- A String message to reply withsuccess
- The Consumer to queue after sending the Message is sent.
-
reply
public void reply(String message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with a String message and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
Either Consumer will be applied to the last message sent if this occurs.- Parameters:
message
- A String message to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
reply
public void reply(net.dv8tion.jda.api.entities.MessageEmbed embed) Replies with aMessageEmbed
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
embed
- The MessageEmbed to reply with
-
reply
public void reply(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessageEmbed
and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.- Parameters:
embed
- The MessageEmbed to reply withsuccess
- The Consumer to queue after sending the Message is sent.
-
reply
public void reply(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessageEmbed
and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.- Parameters:
embed
- The MessageEmbed to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
reply
public void reply(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
message
- The Message to reply with
-
reply
public void reply(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessage
and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#success()
with the provided Consumer as it's success callback.- Parameters:
message
- The Message to reply withsuccess
- The Consumer to success after sending the Message is sent.
-
reply
public void reply(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessage
and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.- Parameters:
message
- The Message to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
reply
Replies with aFile
with the provided name, or a default name if left null.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.This method uses
MessageChannel#sendFile(FileUpload...)
to send the File. For more information on what a bot may send using this, you may find the info in that method.- Parameters:
file
- The File to reply withfilename
- The filename that Discord should display (null for default).
-
reply
Replies with a String message and aFile
with the provided name, or a default name if left null.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.This method uses
MessageChannel#sendFile(FileUpload...)
to send the File. For more information on what a bot may send using this, you may find the info in that method.- Parameters:
message
- A String message to reply withfile
- The File to reply withfilename
- The filename that Discord should display (null for default).
-
replyFormatted
Replies with a formatted String message using the provided arguments.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
format
- A formatted Stringargs
- The arguments to use with the format
-
replyOrAlternate
public void replyOrAlternate(net.dv8tion.jda.api.entities.MessageEmbed embed, String alternateMessage) Replies with aMessageEmbed
if possible, or just a String message if it cannot send the embed.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This alternate String message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
embed
- The MessageEmbed to reply withalternateMessage
- A String message to reply with if the provided MessageEmbed cannot be sent
-
replyOrAlternate
Replies with a String message and aFile
with the provided name, or a default name if left null.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.This method uses
MessageChannel#sendFile(FileUpload...)
to send the File. For more information on what a bot may send using this, you may find the info in that method.NOTE: This alternate String message can exceed the 2000 character cap, and will be sent in two split Messages.
It is also worth noting that unlike
CommandEvent#reply(File, String)
andCommandEvent#reply(String, File, String)
, this method does not throw aIOException
. This is because the cause of the alternate String message being sent comes directly from a thrownException
, and thus a thrown IOException is grounds for the sending of the alternate message.- Parameters:
message
- A String message to reply withfile
- The File to reply withfilename
- The filename that Discord should display (null for default).alternateMessage
- A String message to reply with if the file cannot be uploaded, or anIOException
is thrown
-
replyInDm
Replies with a String message sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This alternate String message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply with
-
replyInDm
Replies with a String message sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.NOTE: This alternate String message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply withsuccess
- The Consumer to queue after sending the Message is sent.
-
replyInDm
public void replyInDm(String message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with a String message sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.NOTE: This alternate String message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.entities.MessageEmbed embed) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
embed
- The MessageEmbed to reply with
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.- Parameters:
embed
- The MessageEmbed to reply withsuccess
- The Consumer to queue after sending the Message is sent.
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.entities.MessageEmbed embed, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessageEmbed
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.- Parameters:
embed
- The MessageEmbed to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
message
- The Message to reply with
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.utils.messages.MessageCreateData message, Consumer<net.dv8tion.jda.api.entities.Message> success) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.- Parameters:
message
- The Message to reply withsuccess
- The Consumer to queue after sending the Message is sent.
-
replyInDm
public void replyInDm(net.dv8tion.jda.api.entities.Message message, Consumer<net.dv8tion.jda.api.entities.Message> success, Consumer<Throwable> failure) Replies with aMessage
sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the first Consumer as it's success callback and the second Consumer as the failure callback.- Parameters:
message
- The Message to reply withsuccess
- The Consumer to queue after sending the Message is sent.failure
- The Consumer to run if an error occurs when sending the Message.
-
replyInDm
Replies with a String message and aFile
with the provided name, or a default name if left null, and sent to the callingUser
'sPrivateChannel
.If the User to be Direct Messaged does not already have a PrivateChannel open to send messages to, this method will automatically open one.
The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.This method uses
MessageChannel#sendFile(FileUpload...)
to send the File. For more information on what a bot may send using this, you may find the info in that method.- Parameters:
message
- A String message to reply withfile
- TheFile
to reply withfilename
- The filename that Discord should display (null for default).
-
replySuccess
Replies with a String message, and a prefixed success emoji.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply with
-
replySuccess
Replies with a String message and a prefixed success emoji and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply withqueue
- The Consumer to queue after sending the Message is sent.
-
replyWarning
Replies with a String message, and a prefixed warning emoji.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply with
-
replyWarning
Replies with a String message and a prefixed warning emoji and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply withqueue
- The Consumer to queue after sending the Message is sent.
-
replyError
Replies with a String message and a prefixed error emoji.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply with
-
replyError
Replies with a String message and a prefixed error emoji and then queues aConsumer
.The
RestAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
with the provided Consumer as it's success callback.NOTE: This message can exceed the 2000 character cap, and will be sent in two split Messages.
- Parameters:
message
- A String message to reply withqueue
- The Consumer to queue after sending the Message is sent.
-
reactSuccess
public void reactSuccess()Adds a success reaction to the callingMessage
. -
reactWarning
public void reactWarning()Adds a warning reaction to the callingMessage
. -
reactError
public void reactError()Adds an error reaction to the callingMessage
. -
async
Uses theclient's executor
to run the providedRunnable
asynchronously without blocking the thread this is called in.The ScheduledExecutorService this runs on can be configured using
CommandClientBuilder#setScheduleExecutor(ScheduledExecutorService)
.- Parameters:
runnable
- The runnable to run async
-
splitMessage
Splits a String into one or more Strings who's length does not exceed 2000 characters.
Also nullifies usages of@here
and@everyone
so that they do not mention anyone.
Useful for splitting long messages so that they can be sent in more than oneMessage
at maximum potential length.- Parameters:
stringtoSend
- The String to split and send- Returns:
- An
ArrayList
containing one or more Strings, with nullified occurrences of@here
and@everyone
, and that do not exceed 2000 characters in length
-
getSelfUser
public net.dv8tion.jda.api.entities.SelfUser getSelfUser()Gets aSelfUser
representing the bot.
This is the same as invokingevent.getJDA().getSelfUser()
.- Returns:
- A User representing the bot
-
getSelfMember
public net.dv8tion.jda.api.entities.Member getSelfMember()Gets aMember
representing the bot, or null if the event does not take place on aGuild
.
This is the same as invokingevent.getGuild().getSelfMember()
.- Returns:
- A possibly-null Member representing the bot
-
isOwner
public boolean isOwner()Tests whether or not theUser
who triggered this event is an owner of the bot.- Returns:
true
if the User is the Owner, elsefalse
-
getAuthor
public net.dv8tion.jda.api.entities.User getAuthor()Gets theUser
who triggered this CommandEvent.- Returns:
- The User who triggered this CommandEvent
-
getChannel
public net.dv8tion.jda.api.entities.channel.middleman.MessageChannel getChannel()Gets theMessageChannel
that the CommandEvent was triggered on.- Returns:
- The MessageChannel that the CommandEvent was triggered on
-
getChannelType
public net.dv8tion.jda.api.entities.channel.ChannelType getChannelType()Gets theChannelType
of theMessageChannel
that the CommandEvent was triggered on.- Returns:
- The ChannelType of the MessageChannel that this CommandEvent was triggered on
-
getGuild
public net.dv8tion.jda.api.entities.Guild getGuild()Gets theGuild
that this CommandEvent was triggered on.- Returns:
- The Guild that this CommandEvent was triggered on
-
getJDA
public net.dv8tion.jda.api.JDA getJDA()Gets the instance ofJDA
that this CommandEvent was caught by.- Returns:
- The instance of JDA that this CommandEvent was caught by
-
getMember
public net.dv8tion.jda.api.entities.Member getMember()Gets theMember
that triggered this CommandEvent.- Returns:
- The Member that triggered this CommandEvent
-
getMessage
public net.dv8tion.jda.api.entities.Message getMessage()Gets theMessage
responsible for triggering this CommandEvent.- Returns:
- The Message responsible for the CommandEvent
-
getPrivateChannel
public net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel getPrivateChannel()Gets thePrivateChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a PrivateChannel.- Returns:
- The PrivateChannel that this CommandEvent may have taken place on, or null if it did not happen on a PrivateChannel.
-
getResponseNumber
public long getResponseNumber()Gets the response number for theMessageReceivedEvent
.- Returns:
- The response number for the MessageReceivedEvent
-
getTextChannel
public net.dv8tion.jda.api.entities.channel.concrete.TextChannel getTextChannel()Gets theTextChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a TextChannel.- Returns:
- The TextChannel this CommandEvent may have taken place on, or null if it did not happen on a TextChannel.
-
getGuildChannel
public net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel getGuildChannel()Gets theGuildMessageChannel
that this CommandEvent may have taken place on, ornull
if it didn't happen on a GuildMessageChannel.- Returns:
- The GuildMessageChannel this CommandEvent may have taken place on, or null if it did not happen on a GuildMessageChannel.
-
isFromType
public boolean isFromType(net.dv8tion.jda.api.entities.channel.ChannelType channelType) Compares a providedChannelType
with the one this CommandEvent occurred on, returningtrue
if they are the same ChannelType.- Parameters:
channelType
- The ChannelType to compare- Returns:
true
if the CommandEvent originated from aMessageChannel
of the provided ChannelType, otherwisefalse
.
-