public interface MessageChannel
Modifier and Type | Method and Description |
---|---|
Message |
sendFile(java.io.File file)
Uploads a file to the Discord servers and sends it to this
TextChannel . |
void |
sendFileAsync(java.io.File file,
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)
Sents 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.
|
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 (30 Messages in 30 secs), a RateLimitedException
is throwntext
- the text to sendRateLimitedException
- when rate-imit is reachedMessage 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 (30 Messages in 30 secs), a RateLimitedException
is thrownmsg
- the Message
to sendMessage
object or null if it failedRateLimitedException
- when rate-imit is reachedvoid 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 sendingvoid 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 sendingMessage sendFile(java.io.File file)
TextChannel
.
Note: This method is blocking, which can cause problems when uploading large files.
Consider sendFileAsync(File, Consumer)
for an alternative.
file
- The file to upload to the TextChannel
.Message
created from this upload.void sendFileAsync(java.io.File file, java.util.function.Consumer<Message> callback)
TextChannel
.file
- The file to upload to the TextChannel
.callback
- Function to deal with the returned Message
after asynchronous uploading completes.void sendTyping()