public class PrivateChannelImpl extends java.lang.Object implements PrivateChannel
Constructor and Description |
---|
PrivateChannelImpl(java.lang.String id,
User user,
JDAImpl api) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getId()
The Id of the
PrivateChannel . |
JDA |
getJDA()
Returns the
JDA instance of this PrivateChannel |
User |
getUser()
The
User that this PrivateChannel communicates with. |
int |
hashCode() |
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 text,
java.util.function.Consumer<Message> callback)
Sents a plain text
Message to this channel. |
void |
sendTyping()
Sends the typing status to discord.
|
java.lang.String |
toString() |
public JDA getJDA()
PrivateChannel
JDA
instance of this PrivateChannelgetJDA
in interface PrivateChannel
public java.lang.String getId()
PrivateChannel
PrivateChannel
. This is typically 18 characters long.getId
in interface PrivateChannel
public User getUser()
PrivateChannel
User
that this PrivateChannel
communicates with.getUser
in interface PrivateChannel
User
.public Message sendMessage(java.lang.String text)
MessageChannel
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 thrownsendMessage
in interface MessageChannel
text
- the text to sendpublic Message sendMessage(Message msg)
MessageChannel
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 thrownsendMessage
in interface MessageChannel
msg
- the Message
to sendMessage
object or null if it failedpublic void sendMessageAsync(java.lang.String text, java.util.function.Consumer<Message> callback)
MessageChannel
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.sendMessageAsync
in interface MessageChannel
text
- the text to sendcallback
- the Callback-function that is called upon successful sendingpublic void sendMessageAsync(Message msg, java.util.function.Consumer<Message> callback)
MessageChannel
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.sendMessageAsync
in interface MessageChannel
msg
- the Message
to sendcallback
- the Callback-function that is called upon successful sendingpublic Message sendFile(java.io.File file)
MessageChannel
TextChannel
.
Note: This method is blocking, which can cause problems when uploading large files.
Consider sendFileAsync(File, Consumer)
for an alternative.
sendFile
in interface MessageChannel
file
- The file to upload to the TextChannel
.Message
created from this upload.public void sendFileAsync(java.io.File file, java.util.function.Consumer<Message> callback)
MessageChannel
TextChannel
.sendFileAsync
in interface MessageChannel
file
- The file to upload to the TextChannel
.callback
- Function to deal with the returned Message
after asynchronous uploading completes.public void sendTyping()
MessageChannel
sendTyping
in interface MessageChannel
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object