public interface MessageChannel
Modifier and Type | Method and Description |
---|---|
boolean |
deleteMessageById(java.lang.String messageId)
Attempts to delete a
Message from the Discord servers
that has the same id as the id provided. |
MessageHistory |
getHistory()
Creates a new
MessageHistory object for each call of this method.This is NOT and internal message cache, but rather it queries the Discord servers for old messages. |
java.lang.String |
getId()
The Id of the Channel.
|
JDA |
getJDA()
Returns the
JDA instance of this MessageChannel |
Message |
getMessageById(java.lang.String messageId)
Attempts to get a
Message from the Discord servers that has
the same id as the id provided. |
java.util.List<Message> |
getPinnedMessages()
Gets a List of
Messages that have been pinned in this channel.If no messages have been pinned, this returns an empty List. |
boolean |
pinMessageById(java.lang.String messageId)
Used to pin a message.
If the provided messageId is invalid or not in this channel, this does nothing. |
Message |
sendFile(java.io.File file,
Message message)
Uploads a file to the Discord servers and sends it to this
TextChannel . |
void |
sendFileAsync(java.io.File file,
Message message,
java.util.function.Consumer<Message> callback)
Asynchronously uploads a file to the Discord servers and sends it to this
TextChannel . |
Message |
sendMessage(Message msg)
|
Message |
sendMessage(java.lang.String text)
Sends a plain text
Message to this channel. |
void |
sendMessageAsync(Message msg,
java.util.function.Consumer<Message> callback)
Sends a given
Message to this Channel
This method only extracts the mentions, text and tts status out of the given Message-Object
Therefore this can also be used to resend already received Messages. |
void |
sendMessageAsync(java.lang.String msg,
java.util.function.Consumer<Message> callback)
Sents a plain text
Message to this channel. |
void |
sendTyping()
Sends the typing status to discord.
|
boolean |
unpinMessageById(java.lang.String messageId)
Used to unpin a message.
If the provided messageId is invalid or not in this channel, this does nothing. |
JDA getJDA()
JDA
instance of this MessageChanneljava.lang.String getId()
Message sendMessage(java.lang.String text)
Message
to this channel.
This will fail if the account of the api does not have the Write-Permission
for this channel set
After the Message has been sent, the created Message
object is returned
This Object will be null, if the sending failed.
When the Rate-limit is reached (10 Messages in 10 secs), a RateLimitedException
is throwntext
- the text to sendRateLimitedException
- when rate-imit is reachedPermissionException
- If this is a TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.BlockedException
- If this is a PrivateChannel
and PMs are blockedVerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.Message sendMessage(Message msg)
Message
to this Channel
This method only extracts the mentions, text and tts status out of the given Message-Object
Therefore this can also be used to resend already received Messages
To allow above behaviour, this method returns a new Message
instance. The passed one is not modified!
If the sending of the Message failed (probably Permissions), this method returns null.
When the Rate-limit is reached (10 Messages in 10 secs), a RateLimitedException
is thrownmsg
- the Message
to sendMessage
object or null if it failedRateLimitedException
- when rate-limit is reachedPermissionException
- If this is a TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.BlockedException
- If this is a PrivateChannel
and PMs are blockedVerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.void sendMessageAsync(java.lang.String msg, java.util.function.Consumer<Message> callback)
Message
to this channel.
After the message has been sent, the corresponding Message
object is passed to the callback-function
This method will wait, and send later, if a Rate-Limit occurs.msg
- the text to sendcallback
- the Callback-function that is called upon successful sending with the Message-object of the sent message or null, if sending failed.
You can pass null as callback, if you do not need the created Message-object.PermissionException
- If this is a TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.VerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.void sendMessageAsync(Message msg, java.util.function.Consumer<Message> callback)
Message
to this Channel
This method only extracts the mentions, text and tts status out of the given Message-Object
Therefore this can also be used to resend already received Messages.
To allow above behaviour, this method calls the callback with a new Message
instance. The passed one is not modified!
This method will wait, and send later, if a Rate-Limit occurs.msg
- the Message
to sendcallback
- the Callback-function that is called upon successful sending with the Message-object of the sent message or null, if sending failed.
You can pass null as callback, if you do not need the created Message-object.PermissionException
- If this is a TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.VerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.Message sendFile(java.io.File file, Message message)
TextChannel
.
Sends the provided Message
with the uploaded file.null
for
the message
parameter.
Note: This method is blocking, which can cause problems when uploading large files.
Consider sendFileAsync(java.io.File, net.dv8tion.jda.entities.Message, java.util.function.Consumer)
for an alternative.
file
- The file to upload to the TextChannel
.message
- The message to be sent along with the uploaded file. This value can be null
.Message
created from this upload.PermissionException
- TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.
TextChannel
and the logged in account does
not have Permission.MESSAGE_ATTACH_FILES
.
VerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.void sendFileAsync(java.io.File file, Message message, java.util.function.Consumer<Message> callback)
TextChannel
.
Sends the provided Message
with the uploaded file.null
for
the message
parameter.file
- The file to upload to the TextChannel
.message
- The message to be sent along with the uploaded file. This value can be null
.callback
- Function to deal with the returned Message
after asynchronous uploading completes.PermissionException
- TextChannel
and the logged in account does
not have Permission.MESSAGE_WRITE
.
TextChannel
and the logged in account does
not have Permission.MESSAGE_ATTACH_FILES
.
VerificationLevelException
- If this is a TextChannel
and you do not meet the required verification-level of the guild.Message getMessageById(java.lang.String messageId)
Message
from the Discord servers that has
the same id as the id provided.messageId
- The id of the sought after MessagePermissionException
- Thrown if:
Permission.MESSAGE_READ
)Permission.MESSAGE_HISTORY
)boolean deleteMessageById(java.lang.String messageId)
Message
from the Discord servers
that has the same id as the id provided.messageId
- The id of the Message which should be deletedPermissionException
- Thrown if:
Permission.MESSAGE_READ
)Permission.MESSAGE_MANAGE
)MessageHistory getHistory()
MessageHistory
object for each call of this method.void sendTyping()
The official discord client sends this every 5 seconds even though the typing status lasts 10.
boolean pinMessageById(java.lang.String messageId)
messageId
- The message to pin.PermissionException
- If this is a TextChannel and this account does not have both
Permission.MESSAGE_READ
and
Permission.MESSAGE_MANAGE
RateLimitedException
- If Discord informs us that this account has accessed this endpoint too often, thus needs to be ratelimited.boolean unpinMessageById(java.lang.String messageId)
messageId
- The message to pin.PermissionException
- If this is a TextChannel and this account does not have both
Permission.MESSAGE_READ
and
Permission.MESSAGE_MANAGE
RateLimitedException
- If Discord informs us that this account has accessed this endpoint too often, thus needs to be ratelimited.java.util.List<Message> getPinnedMessages()
Messages
that have been pinned in this channel.PermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ
RateLimitedException
- If Discord informs us that this account has accessed this endpoint too often, thus needs to be ratelimited.