public class PrivateChannelImpl extends java.lang.Object implements PrivateChannel
Constructor and Description |
---|
PrivateChannelImpl(java.lang.String id,
User user) |
Modifier and Type | Method and Description |
---|---|
RestAction<java.lang.Void> |
close()
Closes a PrivateChannel.
|
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. |
Call |
getCurrentCall() |
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 markerMessage,
int limit) |
RestAction<MessageHistory> |
getHistoryAround(java.lang.String markedMessageId,
int limit) |
java.lang.String |
getId()
The Snowflake id of this entity.
|
JDA |
getJDA()
Returns the
JDA instance of this PrivateChannel |
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() |
User |
getUser()
The
User that this PrivateChannel communicates with. |
boolean |
isFake()
Describes whether an entity is fake or not.
|
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 |
sendTyping()
Sends the typing status to discord.
|
PrivateChannelImpl |
setCurrentCall(Call currentCall) |
PrivateChannelImpl |
setFake(boolean fake) |
RestAction<Call> |
startCall() |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCreationTime
public PrivateChannelImpl(java.lang.String id, User user)
public User getUser()
PrivateChannel
User
that this PrivateChannel
communicates with.getUser
in interface PrivateChannel
User
.public java.lang.String getName()
MessageChannel
Channel.getName()
PrivateChannel.getUser()
.getName()
Group.getName()
getName
in interface MessageChannel
public ChannelType getType()
getType
in interface MessageChannel
public JDA getJDA()
PrivateChannel
JDA
instance of this PrivateChannelgetJDA
in interface MessageChannel
getJDA
in interface PrivateChannel
public RestAction<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 (10 Messages in 10 secs), a RateLimitedException
is thrownsendMessage
in interface MessageChannel
text
- the text to sendpublic RestAction<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 (10 Messages in 10 secs), a RateLimitedException
is thrownsendMessage
in interface MessageChannel
msg
- the Message
to sendMessage
object or null if it failedpublic RestAction<Message> sendFile(java.io.File file, Message message) throws java.io.IOException
MessageChannel
TextChannel
.
Sends the provided Message
with the uploaded file.null
for
the message
parameter.sendFile
in interface MessageChannel
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.java.io.IOException
public RestAction<Message> sendFile(java.io.File file, java.lang.String fileName, Message message) throws java.io.IOException
sendFile
in interface MessageChannel
java.io.IOException
public RestAction<Message> sendFile(java.io.InputStream data, java.lang.String fileName, Message message)
sendFile
in interface MessageChannel
public RestAction<Message> sendFile(byte[] data, java.lang.String fileName, Message message)
sendFile
in interface MessageChannel
public RestAction<Message> getMessageById(java.lang.String messageId)
MessageChannel
Message
from the Discord servers that has
the same id as the id provided.getMessageById
in interface MessageChannel
messageId
- The id of the sought after Messagepublic RestAction<java.lang.Void> deleteMessageById(java.lang.String messageId)
MessageChannel
Message
from the Discord servers
that has the same id as the id provided.deleteMessageById
in interface MessageChannel
messageId
- The id of the Message which should be deletedpublic MessageHistory getHistory()
MessageChannel
MessageHistory
object for each call of this method.getHistory
in interface MessageChannel
public RestAction<MessageHistory> getHistoryAround(Message markerMessage, int limit)
getHistoryAround
in interface MessageChannel
public RestAction<MessageHistory> getHistoryAround(java.lang.String markedMessageId, int limit)
getHistoryAround
in interface MessageChannel
public RestAction sendTyping()
MessageChannel
The official discord client sends this every 5 seconds even though the typing status lasts 10.
sendTyping
in interface MessageChannel
RestAction
.public RestAction<java.lang.Void> pinMessageById(java.lang.String messageId)
MessageChannel
pinMessageById
in interface MessageChannel
messageId
- The message to pin.RestAction
<Void
>public RestAction<java.lang.Void> unpinMessageById(java.lang.String messageId)
MessageChannel
unpinMessageById
in interface MessageChannel
messageId
- The message to pin.public RestAction<java.util.List<Message>> getPinnedMessages()
MessageChannel
Messages
that have been pinned in this channel.getPinnedMessages
in interface MessageChannel
RestAction<List<Message>>
public RestAction<java.lang.Void> close()
PrivateChannel
close
in interface PrivateChannel
RestAction
public java.lang.String getId()
ISnowflake
getId
in interface ISnowflake
public boolean isFake()
IFakeable
public RestAction<Call> startCall()
startCall
in interface CallableChannel
public Call getCurrentCall()
getCurrentCall
in interface CallableChannel
public PrivateChannelImpl setFake(boolean fake)
public PrivateChannelImpl setCurrentCall(Call currentCall)