public interface MessageChannel extends ISnowflake
Modifier and Type | Method and Description |
---|---|
RestAction<java.lang.Void> |
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. |
RestAction<MessageHistory> |
getHistoryAround(Message message,
int limit) |
RestAction<MessageHistory> |
getHistoryAround(java.lang.String messageId,
int limit) |
JDA |
getJDA()
Returns the
JDA instance of this MessageChannel |
RestAction<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.lang.String |
getName()
This method is a shortcut method to return the following information in the following situation:
If the MessageChannel is instance of..
|
RestAction<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. |
ChannelType |
getType() |
RestAction<java.lang.Void> |
pinMessageById(java.lang.String messageId)
Used to pin a message.
If the provided messageId is invalid or not in this channel, this does nothing. |
RestAction<Message> |
sendFile(byte[] data,
java.lang.String fileName,
Message message) |
RestAction<Message> |
sendFile(java.io.File file,
Message message)
Uploads a file to the Discord servers and sends it to this
TextChannel . |
RestAction<Message> |
sendFile(java.io.File file,
java.lang.String fileName,
Message message) |
RestAction<Message> |
sendFile(java.io.InputStream data,
java.lang.String fileName,
Message message) |
RestAction<Message> |
sendMessage(Message msg)
|
RestAction<Message> |
sendMessage(java.lang.String text)
Sends a plain text
Message to this channel. |
RestAction<java.lang.Void> |
sendTyping()
Sends the typing status to discord.
|
RestAction<java.lang.Void> |
unpinMessageById(java.lang.String messageId)
Used to unpin a message.
If the provided messageId is invalid or not in this channel, this does nothing. |
getCreationTime, getId
java.lang.String getName()
Channel.getName()
PrivateChannel.getUser()
.getName()
Group.getName()
ChannelType getType()
JDA getJDA()
JDA
instance of this MessageChannelRestAction<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
.net.dv8tion.jda.core.exceptions.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.RestAction<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
.net.dv8tion.jda.core.exceptions.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.RestAction<Message> sendFile(java.io.File file, Message message) throws java.io.IOException
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
.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.java.io.IOException
RestAction<Message> sendFile(java.io.File file, java.lang.String fileName, Message message) throws java.io.IOException
java.io.IOException
RestAction<Message> sendFile(java.io.InputStream data, java.lang.String fileName, Message message)
RestAction<Message> sendFile(byte[] data, java.lang.String fileName, Message message)
RestAction<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
)RestAction<java.lang.Void> 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.RestAction<MessageHistory> getHistoryAround(Message message, int limit)
RestAction<MessageHistory> getHistoryAround(java.lang.String messageId, int limit)
RestAction<java.lang.Void> sendTyping()
The official discord client sends this every 5 seconds even though the typing status lasts 10.
RestAction
.RestAction<java.lang.Void> pinMessageById(java.lang.String messageId)
messageId
- The message to pin.RestAction
<Void
>PermissionException
- If this is a TextChannel and this account does not have both
Permission.MESSAGE_READ
and
Permission.MESSAGE_MANAGE
RestAction<java.lang.Void> 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
RestAction<java.util.List<Message>> getPinnedMessages()
Messages
that have been pinned in this channel.RestAction<List<Message>>
PermissionException
- If this is a TextChannel and this account does not have
Permission.MESSAGE_READ