public class TextChannelImpl extends java.lang.Object implements TextChannel
Constructor and Description |
---|
TextChannelImpl(java.lang.String id,
Guild guild) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TextChannel chan) |
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. |
RestAction<java.lang.Void> |
deleteMessages(java.util.Collection<Message> messages)
Bulk deletes a list of messages.
|
RestAction<java.lang.Void> |
deleteMessagesByIds(java.util.Collection<java.lang.String> messageIds)
Bulk deletes a list of messages.
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getAsMention()
Retrieve a Mention for this Entity.
|
Guild |
getGuild()
Returns the
Guild that this Channel is part of. |
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 Snowflake id of this entity.
|
JDA |
getJDA()
Returns the
JDA instance of this Channel |
java.util.HashMap<Member,PermissionOverride> |
getMemberOverrideMap() |
java.util.List<PermissionOverride> |
getMemberPermissionOverrides()
|
java.util.List<Member> |
getMembers()
A List of all
Members that are in this Channel
For TextChannels , this returns all Members with the Permission.MESSAGE_READ Permission. |
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()
The human readable name of the Channel.
If no name has been set, this returns null. |
PermissionOverride |
getOverrideForMember(Member member)
The
PermissionOverride relating to the specified User . |
PermissionOverride |
getOverrideForRole(Role role)
The
PermissionOverride relating to the specified Role . |
java.util.List<PermissionOverride> |
getPermissionOverrides()
Gets all of the
PermissionOverrides that are part
of this Channel .This combines User and Role overrides. |
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. |
int |
getPosition()
The position this Channel is displayed at.
Higher values mean they are displayed lower in the Client. |
int |
getPositionRaw()
The actual position of the
Channel as stored and given by Discord. |
java.util.HashMap<Role,PermissionOverride> |
getRoleOverrideMap() |
java.util.List<PermissionOverride> |
getRolePermissionOverrides()
|
java.lang.String |
getTopic()
The topic set for this TextChannel.
|
int |
hashCode() |
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(java.io.File file,
Message message)
Uploads a file to the Discord servers and sends it to this
TextChannel . |
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.
|
TextChannelImpl |
setName(java.lang.String name) |
TextChannelImpl |
setRawPosition(int rawPosition) |
TextChannelImpl |
setTopic(java.lang.String topic) |
java.lang.String |
toString() |
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, finalize, getClass, notify, notifyAll, wait, wait, wait
getCreationTime
public TextChannelImpl(java.lang.String id, Guild guild)
public java.lang.String getAsMention()
IMentionable
getAsMention
in interface IMentionable
public java.lang.String getId()
ISnowflake
getId
in interface ISnowflake
public RestAction<java.lang.Void> deleteMessages(java.util.Collection<Message> messages)
TextChannel
Message.deleteMessage()
in a loop.
Must be at least 2 messages and not be more than 100 messages at a time.
If you only have 1 message, use the Message.deleteMessage()
method.
You must have Permission.MESSAGE_MANAGE
in this channel to use
this function.
This method is best used when using MessageHistory
to delete a large amount
of messages. If you have a large amount of messages but only their message Ids, please use
TextChannel.deleteMessagesByIds(java.util.Collection)
deleteMessages
in interface TextChannel
messages
- The messages to delete.RestAction
public RestAction<java.lang.Void> deleteMessagesByIds(java.util.Collection<java.lang.String> messageIds)
TextChannel
MessageChannel.deleteMessageById(String)
in a loop.
Must be at least 2 messages and not be more than 100 messages at a time.
If you only have 1 message, use the Message.deleteMessage()
method.
You must have Permission.MESSAGE_MANAGE
in this channel to use
this function.
This method is best used when you have a large amount of messages but only their message Ids. If you are using
MessageHistory
or have Message
objects, it would be easier to use TextChannel.deleteMessages(java.util.Collection)
.
deleteMessagesByIds
in interface TextChannel
messageIds
- The messages to delete.RestAction
public java.lang.String getName()
Channel
getName
in interface Channel
getName
in interface MessageChannel
public java.lang.String getTopic()
TextChannel
getTopic
in interface TextChannel
public Guild getGuild()
Channel
Guild
that this Channel is part of.public java.util.List<Member> getMembers()
Channel
Members
that are in this Channel
For TextChannels
, this returns all Members with the Permission.MESSAGE_READ
Permission.
In VoiceChannels
, this returns all Members that joined that VoiceChannel.getMembers
in interface Channel
Members
that are in this Channel.public int getPosition()
Channel
Guild
do not have to have continuous positionsgetPosition
in interface Channel
public int getPositionRaw()
Channel
Channel
as stored and given by Discord.
Role positions are actually based on a pairing of the creation time (as stored in the snowflake id)
and the position. If 2 or more roles share the same position then they are sorted based on their creation date.
The more recent a role was created, the lower it is in the hierachy. This is handled by Channel.getPosition()
and it is most likely the method you want. If, for some reason, you want the actual position of the
Role then this method will give you that value.getPositionRaw
in interface Channel
Channel
.public JDA getJDA()
Channel
JDA
instance of this ChannelgetJDA
in interface Channel
getJDA
in interface MessageChannel
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)
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.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<java.lang.Void> 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 PermissionOverride getOverrideForMember(Member member)
Channel
PermissionOverride
relating to the specified User
.
If there is no PermissionOverride
for this Channel
relating to the provided User
, then this returns null
.getOverrideForMember
in interface Channel
member
- The Member
whose PermissionOverride
is requested.PermissionOverride
relating to the provided User
.public PermissionOverride getOverrideForRole(Role role)
Channel
PermissionOverride
relating to the specified Role
.
If there is no PermissionOverride
for this Channel
relating to the provided Role
, then this returns null
.getOverrideForRole
in interface Channel
role
- The Role
whose PermissionOverride
is requested.PermissionOverride
relating to the provided Role
.public java.util.List<PermissionOverride> getPermissionOverrides()
Channel
PermissionOverrides
that are part
of this Channel
.User
and Role
overrides.
If you would like only User
overrides or only Role
overrides, use Channel.getMemberPermissionOverrides()
()} or Channel.getRolePermissionOverrides()
respectively.getPermissionOverrides
in interface Channel
PermissionOverrides
for this Channel
.public java.util.List<PermissionOverride> getMemberPermissionOverrides()
Channel
getMemberPermissionOverrides
in interface Channel
PermissionOverrides
for Member
for this Channel
.public java.util.List<PermissionOverride> getRolePermissionOverrides()
Channel
getRolePermissionOverrides
in interface Channel
PermissionOverrides
for Roles
for this Channel
.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
public int compareTo(TextChannel chan)
compareTo
in interface java.lang.Comparable<TextChannel>
public TextChannelImpl setName(java.lang.String name)
public TextChannelImpl setTopic(java.lang.String topic)
public TextChannelImpl setRawPosition(int rawPosition)
public java.util.HashMap<Member,PermissionOverride> getMemberOverrideMap()
public java.util.HashMap<Role,PermissionOverride> getRoleOverrideMap()