public class TextChannelImpl extends TextChannel
Modifier and Type | Class and Description |
---|---|
static class |
TextChannelImpl.AsyncMessageSender |
Constructor and Description |
---|
TextChannelImpl(java.lang.String id,
Guild guild) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkPermission(User user,
Permission perm)
Checks if the given
User has the given Permission
in this Channel |
PermissionOverrideManager |
createPermissionOverride(Role role)
Creates a new
PermissionOverride for a given Role . |
PermissionOverrideManager |
createPermissionOverride(User user)
Creates a new
PermissionOverride for a given User . |
boolean |
equals(java.lang.Object o) |
Guild |
getGuild()
Returns the
Guild that this Channel is part of. |
java.lang.String |
getId()
The Id of the Channel.
|
JDA |
getJDA()
Returns the
JDA instance of this Channel |
ChannelManager |
getManager()
Returns the
ChannelManager for this Channel. |
java.lang.String |
getName()
The human readable name of the Channel.
If no name has been set, this returns null. |
PermissionOverride |
getOverrideForRole(Role role)
The
PermissionOverride relating to the specified Role . |
PermissionOverride |
getOverrideForUser(User user)
The
PermissionOverride relating to the specified User . |
java.util.List<PermissionOverride> |
getPermissionOverrides()
Gets all of the
PermissionOverrides that are part
of this Channel .This combines User and Role overrides. |
int |
getPosition()
The position this Channel is displayed at.
Higher values mean they are displayed lower in the Client. |
java.util.List<PermissionOverride> |
getRolePermissionOverrides()
|
java.util.Map<Role,PermissionOverride> |
getRolePermissionOverridesMap() |
java.lang.String |
getTopic()
The topic set for this Channel.
|
java.util.List<PermissionOverride> |
getUserPermissionOverrides()
|
java.util.Map<User,PermissionOverride> |
getUserPermissionOverridesMap() |
java.util.List<User> |
getUsers()
A List of all
Users that are in this Channel
For TextChannels , this returns all Users with the Permission.MESSAGE_READ Permission. |
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.
|
TextChannelImpl |
setName(java.lang.String name) |
TextChannelImpl |
setPosition(int position) |
TextChannelImpl |
setTopic(java.lang.String topic) |
java.lang.String |
toString() |
public TextChannelImpl(java.lang.String id, Guild guild)
public JDA getJDA()
Channel
JDA
instance of this Channelpublic PermissionOverride getOverrideForUser(User user)
Channel
PermissionOverride
relating to the specified User
.
If there is no PermissionOverride
for this Channel
relating to the provided User
, then this returns null
.user
- The User
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
.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.getUserPermissionOverrides()
or Channel.getRolePermissionOverrides()
respectively.PermissionOverrides
for this Channel
.public java.util.List<PermissionOverride> getUserPermissionOverrides()
Channel
PermissionOverrides
for Users
for this Channel
.public java.util.List<PermissionOverride> getRolePermissionOverrides()
Channel
PermissionOverrides
for Roles
for this Channel
.public java.lang.String getId()
Channel
public java.lang.String getName()
Channel
public java.lang.String getTopic()
Channel
public Guild getGuild()
Channel
Guild
that this Channel is part of.Guild
that this Channel is part of.public java.util.List<User> getUsers()
Channel
Users
that are in this Channel
For TextChannels
, this returns all Users with the Permission.MESSAGE_READ
Permission.
In VoiceChannels
, this returns all Users that joined that VoiceChannel.Users
that are in this Channel.public int getPosition()
Channel
Guild
do not have to have continuous positionspublic 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 throwntext
- 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 thrownpublic 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.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.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.
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
.file
- The file to upload to the TextChannel
.callback
- Function to deal with the returned Message
after asynchronous uploading completes.public void sendTyping()
MessageChannel
public boolean checkPermission(User user, Permission perm)
Channel
User
has the given Permission
in this Channeluser
- the User to check the Permission againstperm
- the Permission to check forpublic ChannelManager getManager()
Channel
ChannelManager
for this Channel.
In the ChannelManager, you can modify the name, topic and position of this Channel.public PermissionOverrideManager createPermissionOverride(User user)
Channel
PermissionOverride
for a given User
.
For this to be successful, the logged in account has to have the MANAGE_PERMISSIONS Permission
user
- the User to create an Override forpublic PermissionOverrideManager createPermissionOverride(Role role)
Channel
PermissionOverride
for a given Role
.
For this to be successful, the logged in account has to have the MANAGE_PERMISSIONS Permission
role
- the Role to create an Override forpublic TextChannelImpl setName(java.lang.String name)
public TextChannelImpl setTopic(java.lang.String topic)
public TextChannelImpl setPosition(int position)
public java.util.Map<User,PermissionOverride> getUserPermissionOverridesMap()
public java.util.Map<Role,PermissionOverride> getRolePermissionOverridesMap()
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