Interface TextChannel
-
- All Superinterfaces:
AbstractChannel
,java.lang.Comparable<GuildChannel>
,java.util.Formattable
,GuildChannel
,IMentionable
,ISnowflake
,MessageChannel
public interface TextChannel extends GuildChannel, MessageChannel
Represents a Discord Text GuildChannel.
Adds additional functionality and information for text channels in Discord.This is a
GuildChannel
capable of sending messages.- See Also:
GuildChannel
,MessageChannel
,VoiceChannel
,Category
,Guild.getTextChannelCache()
,Guild.getTextChannels()
,Guild.getTextChannelsByName(String, boolean)
,Guild.getTextChannelById(long)
,JDA.getTextChannelCache()
,JDA.getTextChannels()
,JDA.getTextChannelsByName(String, boolean)
,JDA.getTextChannelById(long)
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_SLOWMODE
The maximum duration of slowmode in seconds
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canTalk()
Whether we can send messages in this channel.boolean
canTalk(Member member)
Whether the specifiedMember
can send messages in this channel.default RestAction<java.lang.Void>
clearReactionsById(long messageId)
Attempts to remove all reactions from a message with the specifiedmessageId
in this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.default RestAction<java.lang.Void>
clearReactionsById(long messageId, java.lang.String unicode)
Removes all reactions for the specified emoji.default RestAction<java.lang.Void>
clearReactionsById(long messageId, Emote emote)
Removes all reactions for the specified emoji.RestAction<java.lang.Void>
clearReactionsById(java.lang.String messageId)
Attempts to remove all reactions from a message with the specifiedmessageId
in this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.RestAction<java.lang.Void>
clearReactionsById(java.lang.String messageId, java.lang.String unicode)
Removes all reactions for the specified emoji.RestAction<java.lang.Void>
clearReactionsById(java.lang.String messageId, Emote emote)
Removes all reactions for the specified emoji.ChannelAction<TextChannel>
createCopy()
Creates a copy of the specifiedGuildChannel
.ChannelAction<TextChannel>
createCopy(Guild guild)
Creates a copy of the specifiedGuildChannel
in the specifiedGuild
.WebhookAction
createWebhook(java.lang.String name)
Creates a newWebhook
.default RestAction<Message>
crosspostMessageById(long messageId)
Attempts to crosspost the provided message.default RestAction<Message>
crosspostMessageById(java.lang.String messageId)
Attempts to crosspost the provided message.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.AuditableRestAction<java.lang.Void>
deleteWebhookById(java.lang.String id)
Deletes aWebhook
attached to this channel by theid
specified.default RestAction<Webhook.WebhookReference>
follow(long targetChannelId)
Subscribes to the crossposted messages in this channel.RestAction<Webhook.WebhookReference>
follow(java.lang.String targetChannelId)
Subscribes to the crossposted messages in this channel.default RestAction<Webhook.WebhookReference>
follow(TextChannel targetChannel)
Subscribes to the crossposted messages in this channel.default void
formatTo(java.util.Formatter formatter, int flags, int width, int precision)
int
getSlowmode()
The slowmode set for this TextChannel.java.lang.String
getTopic()
The topic set for this TextChannel.boolean
isNews()
Whether or not this channel is considered an Announcement-/News-Channel.boolean
isNSFW()
Whether or not this channel is considered as "NSFW" (Not-Safe-For-Work)default RestAction<java.lang.Void>
removeReactionById(long messageId, java.lang.String unicode, User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.default RestAction<java.lang.Void>
removeReactionById(long messageId, Emote emote, User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.RestAction<java.lang.Void>
removeReactionById(java.lang.String messageId, java.lang.String unicode, User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.default RestAction<java.lang.Void>
removeReactionById(java.lang.String messageId, Emote emote, User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.RestAction<java.util.List<Webhook>>
retrieveWebhooks()
Retrieves theWebhooks
attached to this TextChannel.-
Methods inherited from interface net.dv8tion.jda.api.entities.AbstractChannel
getJDA, getName, getType
-
Methods inherited from interface net.dv8tion.jda.api.entities.GuildChannel
createInvite, createPermissionOverride, delete, getGuild, getManager, getMemberPermissionOverrides, getMembers, getParent, getPermissionOverride, getPermissionOverrides, getPosition, getPositionRaw, getRolePermissionOverrides, isSynced, putPermissionOverride, retrieveInvites, upsertPermissionOverride
-
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
getAsMention
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Methods inherited from interface net.dv8tion.jda.api.entities.MessageChannel
addReactionById, addReactionById, addReactionById, addReactionById, deleteMessageById, deleteMessageById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, getHistory, getHistoryAfter, getHistoryAfter, getHistoryAfter, getHistoryAround, getHistoryAround, getHistoryAround, getHistoryBefore, getHistoryBefore, getHistoryBefore, getHistoryFromBeginning, getIterableHistory, getLatestMessageId, getLatestMessageIdLong, hasLatestMessage, pinMessageById, pinMessageById, purgeMessages, purgeMessages, purgeMessagesById, purgeMessagesById, purgeMessagesById, removeReactionById, removeReactionById, removeReactionById, removeReactionById, retrieveMessageById, retrieveMessageById, retrievePinnedMessages, retrieveReactionUsersById, retrieveReactionUsersById, retrieveReactionUsersById, retrieveReactionUsersById, sendFile, sendFile, sendFile, sendFile, sendMessage, sendMessage, sendMessage, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendTyping, unpinMessageById, unpinMessageById
-
-
-
-
Field Detail
-
MAX_SLOWMODE
static final int MAX_SLOWMODE
The maximum duration of slowmode in seconds- See Also:
- Constant Field Values
-
-
Method Detail
-
getTopic
@Nullable java.lang.String getTopic()
The topic set for this TextChannel.
If no topic has been set, this returns null.- Returns:
- Possibly-null String containing the topic of this TextChannel.
-
isNSFW
boolean isNSFW()
Whether or not this channel is considered as "NSFW" (Not-Safe-For-Work)- Returns:
- True, If this TextChannel is considered NSFW by the official Discord Client
-
isNews
boolean isNews()
Whether or not this channel is considered an Announcement-/News-Channel.
These channels can be used to crosspost messages to other guilds by using a follower type webhook.- Returns:
- True, if this is considered a news channel
- Since:
- 4.2.1
-
getSlowmode
int getSlowmode()
The slowmode set for this TextChannel.
If slowmode is set this returns anint
between 1 andTextChannel.MAX_SLOWMODE
.
If not set this returns0
.Note bots are unaffected by this.
HavingMESSAGE_MANAGE
orMANAGE_CHANNEL
permission also grants immunity to slowmode.- Returns:
- The slowmode for this TextChannel, between 1 and
TextChannel.MAX_SLOWMODE
, or0
if no slowmode is set.
-
createCopy
@Nonnull ChannelAction<TextChannel> createCopy(@Nonnull Guild guild)
Description copied from interface:GuildChannel
Creates a copy of the specifiedGuildChannel
in the specifiedGuild
.
If the provided target guild is not the same Guild this channel is in then the parent category and permissions will not be copied due to technical difficulty and ambiguity.This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW, Slowmode)
- All permission overrides for Members/Roles
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removed
- Specified by:
createCopy
in interfaceGuildChannel
- Parameters:
guild
- TheGuild
to create the channel in- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it!
-
createCopy
@Nonnull ChannelAction<TextChannel> createCopy()
Description copied from interface:GuildChannel
Creates a copy of the specifiedGuildChannel
.This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW, Slowmode)
- All permission overrides for Members/Roles
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removed
- Specified by:
createCopy
in interfaceGuildChannel
- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it!
-
retrieveWebhooks
@Nonnull @CheckReturnValue RestAction<java.util.List<Webhook>> retrieveWebhooks()
Retrieves theWebhooks
attached to this TextChannel.Possible ErrorResponses include:
UNKNOWN_CHANNEL
if this channel was deletedMISSING_ACCESS
if we were removed from the guild
- Returns:
RestAction
- Type: List<Webhook
>
Retrieved an immutable list of Webhooks attached to this channel
-
createWebhook
@Nonnull @CheckReturnValue WebhookAction createWebhook(@Nonnull java.lang.String name)
Creates a newWebhook
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The webhook could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removedMAX_WEBHOOKS
If the channel already has reached the maximum capacity for webhooks
- Parameters:
name
- The default name for the new Webhook.- Returns:
- A specific
WebhookAction
This action allows to set fields for the new webhook before creating it - Throws:
PermissionException
- If you do not hold the permissionManage Webhooks
java.lang.IllegalArgumentException
- If the provided name isnull
, blank or not between 2-100 characters in length
-
follow
@Nonnull @CheckReturnValue RestAction<Webhook.WebhookReference> follow(@Nonnull java.lang.String targetChannelId)
Subscribes to the crossposted messages in this channel.
This will create aWebhook
of typeFOLLOWER
in the target channel.Possible
ErrorResponses
include:UNKNOWN_CHANNEL
If the target channel doesn't exist or is not visible to the currently logged in accountMISSING_PERMISSIONS
If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in the target channelMAX_WEBHOOKS
If the target channel already has reached the maximum capacity for webhooks
- Parameters:
targetChannelId
- The target channel id- Returns:
RestAction
- Throws:
java.lang.IllegalArgumentException
- If null is providedjava.lang.IllegalStateException
- If this is not a news channels (SeeisNews()
)- Since:
- 4.2.1
-
follow
@Nonnull @CheckReturnValue default RestAction<Webhook.WebhookReference> follow(long targetChannelId)
Subscribes to the crossposted messages in this channel.
This will create aWebhook
of typeFOLLOWER
in the target channel.Possible
ErrorResponses
include:UNKNOWN_CHANNEL
If the target channel doesn't exist or not visible to the currently logged in accountMISSING_PERMISSIONS
If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in the target channelMAX_WEBHOOKS
If the target channel already has reached the maximum capacity for webhooks
- Parameters:
targetChannelId
- The target channel id- Returns:
RestAction
- Throws:
java.lang.IllegalStateException
- If this is not a news channels (SeeisNews()
)- Since:
- 4.2.1
-
follow
@Nonnull @CheckReturnValue default RestAction<Webhook.WebhookReference> follow(@Nonnull TextChannel targetChannel)
Subscribes to the crossposted messages in this channel.
This will create aWebhook
of typeFOLLOWER
in the target channel.Possible
ErrorResponses
include:UNKNOWN_CHANNEL
If the target channel doesn't exist or not visible to the currently logged in accountMISSING_PERMISSIONS
If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in the target channelMAX_WEBHOOKS
If the target channel already has reached the maximum capacity for webhooks
- Parameters:
targetChannel
- The target channel- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in the target channel.java.lang.IllegalArgumentException
- If null is providedjava.lang.IllegalStateException
- If this is not a news channels (SeeisNews()
)- Since:
- 4.2.1
-
deleteMessages
@Nonnull @CheckReturnValue RestAction<java.lang.Void> deleteMessages(@Nonnull java.util.Collection<Message> messages)
Bulk deletes a list of messages. This is not the same as callingMessage.delete()
in a loop.
This is much more efficient, but it has a different ratelimit. You may call this once per second per Guild.Must be at least 2 messages and not be more than 100 messages at a time.
If you only have 1 message, use theMessage.delete()
method instead.You must have the 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 usedeleteMessagesByIds(Collection)
Possible ErrorResponses include:
UNKNOWN_CHANNEL
if this channel was deletedUNKNOWN_MESSAGE
if any of the provided messages does not existMISSING_ACCESS
if we were removed from the guildMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_MANAGE
in the channel.
- Parameters:
messages
- The collection of messages to delete.- Returns:
AuditableRestAction
- Throws:
java.lang.IllegalArgumentException
- If the size of the list less than 2 or more than 100 messages.InsufficientPermissionException
- If this account does not havePermission.MESSAGE_MANAGE
- See Also:
deleteMessagesByIds(Collection)
,MessageChannel.purgeMessages(List)
-
deleteMessagesByIds
@Nonnull @CheckReturnValue RestAction<java.lang.Void> deleteMessagesByIds(@Nonnull java.util.Collection<java.lang.String> messageIds)
Bulk deletes a list of messages. This is not the same as callingMessageChannel.deleteMessageById(String)
in a loop.
This is much more efficient, but it has a different ratelimit. You may call this once per second per Guild.Must be at least 2 messages and not be more than 100 messages at a time.
If you only have 1 message, use theMessage.delete()
method instead.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 haveMessage
objects, it would be easier to usedeleteMessages(java.util.Collection)
.Possible ErrorResponses include:
UNKNOWN_CHANNEL
if this channel was deletedUNKNOWN_MESSAGE
if any of the provided messages does not existMISSING_ACCESS
if we were removed from the guildMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MESSAGE_MANAGE
in the channel.
- Parameters:
messageIds
- The message ids for the messages to delete.- Returns:
AuditableRestAction
- Throws:
java.lang.IllegalArgumentException
- If the size of the list less than 2 or more than 100 messages.java.lang.NumberFormatException
- If any of the provided ids cannot be parsed byLong.parseLong(String)
InsufficientPermissionException
- If this account does not havePermission.MESSAGE_MANAGE
- See Also:
deleteMessages(Collection)
,MessageChannel.purgeMessagesById(List)
-
deleteWebhookById
@Nonnull @CheckReturnValue AuditableRestAction<java.lang.Void> deleteWebhookById(@Nonnull java.lang.String id)
Deletes aWebhook
attached to this channel by theid
specified.Possible ErrorResponses include:
ErrorResponse.UNKNOWN_WEBHOOK
The provided id does not refer to a WebHook present in this TextChannel, either due to it not existing or having already been deleted.UNKNOWN_CHANNEL
if this channel was deletedMISSING_ACCESS
if we were removed from the guildMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MANAGE_WEBHOOKS
in the channel.
- Parameters:
id
- The not-null id for the target Webhook.- Returns:
AuditableRestAction
- Throws:
java.lang.IllegalArgumentException
- If the providedid
isnull
or empty.InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_WEBHOOKS
in this channel.
-
clearReactionsById
@Nonnull @CheckReturnValue RestAction<java.lang.Void> clearReactionsById(@Nonnull java.lang.String messageId)
Attempts to remove all reactions from a message with the specifiedmessageId
in this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.The following
ErrorResponses
are possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChannel
due toPermission.MESSAGE_READ
being revoked, or the account lost access to theGuild
typically due to being kicked or removed.MISSING_PERMISSIONS
The clear-reactions request was attempted after the account lostPermission.MESSAGE_MANAGE
in theTextChannel
when adding the reaction.UNKNOWN_MESSAGE
The clear-reactions request was attempted after the Message had been deleted.
- Parameters:
messageId
- The not-empty valid message id- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.java.lang.IllegalArgumentException
- If the providedid
isnull
or empty.
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> clearReactionsById(long messageId)
Attempts to remove all reactions from a message with the specifiedmessageId
in this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.The following
ErrorResponses
are possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChannel
due toPermission.MESSAGE_READ
being revoked, or the account lost access to theGuild
typically due to being kicked or removed.MISSING_PERMISSIONS
The clear-reactions request was attempted after the account lostPermission.MESSAGE_MANAGE
in theTextChannel
when adding the reaction.UNKNOWN_MESSAGE
The clear-reactions request was attempted after the Message had been deleted.
- Parameters:
messageId
- The message id- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.
-
clearReactionsById
@Nonnull @CheckReturnValue RestAction<java.lang.Void> clearReactionsById(@Nonnull java.lang.String messageId, @Nonnull java.lang.String unicode)
Removes all reactions for the specified emoji.Example
// custom channel.clearReactions(messageId, "minn:245267426227388416").queue(); // unicode escape channel.clearReactions(messageId, "\uD83D\uDE02").queue(); // codepoint notation channel.clearReactions(messageId, "U+1F602").queue();
The following
ErrorResponses
are possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNEL
permissionUNKNOWN_EMOJI
The provided unicode emoji doesn't exist. Try using one of the example formats.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId
- The id for the target messageunicode
- The unicode emoji to remove reactions for- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in the channeljava.lang.IllegalArgumentException
- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue RestAction<java.lang.Void> clearReactionsById(@Nonnull java.lang.String messageId, @Nonnull Emote emote)
Removes all reactions for the specified emoji.The following
ErrorResponses
are possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNEL
permissionUNKNOWN_EMOJI
The providedEmote
was deleted or doesn't exist.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId
- The id for the target messageemote
- TheEmote
to remove reactions for- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in the channeljava.lang.IllegalArgumentException
- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> clearReactionsById(long messageId, @Nonnull java.lang.String unicode)
Removes all reactions for the specified emoji.Example
// custom channel.clearReactions(messageId, "minn:245267426227388416").queue(); // unicode escape channel.clearReactions(messageId, "\uD83D\uDE02").queue(); // codepoint notation channel.clearReactions(messageId, "U+1F602").queue();
The following
ErrorResponses
are possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNEL
permissionUNKNOWN_EMOJI
The provided unicode emoji doesn't exist. Try using one of the example formats.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId
- The id for the target messageunicode
- The unicode emoji to remove reactions for- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in the channeljava.lang.IllegalArgumentException
- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> clearReactionsById(long messageId, @Nonnull Emote emote)
Removes all reactions for the specified emoji.The following
ErrorResponses
are possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNEL
permissionUNKNOWN_EMOJI
The providedEmote
was deleted or doesn't exist.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId
- The id for the target messageemote
- TheEmote
to remove reactions for- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in the channeljava.lang.IllegalArgumentException
- If provided with null- Since:
- 4.2.0
-
removeReactionById
@Nonnull @CheckReturnValue RestAction<java.lang.Void> removeReactionById(@Nonnull java.lang.String messageId, @Nonnull java.lang.String unicode, @Nonnull User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.
The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORY
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTION
in theTextChannel
.ErrorResponse.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to remove the reaction fromunicode
- The unicode characters of the emojiuser
- The target user of which to remove from- Returns:
RestAction
- Throws:
java.lang.IllegalArgumentException
-- If provided
messageId
isnull
or empty. - If provided
unicode
isnull
or empty.
- If provided
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> removeReactionById(long messageId, @Nonnull java.lang.String unicode, @Nonnull User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.The unicode provided has to be a unicode representation of the emoji that is supposed to be represented by the Reaction.
To retrieve the characters needed you can use an api or the official discord client by escaping the emoji (\:emoji-name:) and copying the resulting emoji from the sent message.This method encodes the provided unicode for you. Do not encode the emoji before providing the unicode.
The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORY
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTION
in theTextChannel
.ErrorResponse.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to remove the reaction fromunicode
- The unicode characters of the emojiuser
- The target user of which to remove from- Returns:
RestAction
- Throws:
java.lang.IllegalArgumentException
-- If provided
messageId
isnull
or empty. - If provided
unicode
isnull
or empty.
- If provided
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> removeReactionById(@Nonnull java.lang.String messageId, @Nonnull Emote emote, @Nonnull User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORY
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTION
in theTextChannel
.ErrorResponse.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to remove the reaction fromemote
- The emote to removeuser
- The target user of which to remove from- Returns:
RestAction
- Throws:
java.lang.IllegalArgumentException
-- If provided
messageId
isnull
or empty. - If provided
emote
isnull
.
- If provided
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<java.lang.Void> removeReactionById(long messageId, @Nonnull Emote emote, @Nonnull User user)
Attempts to remove the reaction from a message represented by the specifiedmessageId
in this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponses
are possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORY
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTION
in theTextChannel
.ErrorResponse.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to remove the reaction fromemote
- The emote to removeuser
- The target user of which to remove from- Returns:
RestAction
- Throws:
java.lang.IllegalArgumentException
-- If provided
messageId
isnull
or empty. - If provided
emote
isnull
.
- If provided
InsufficientPermissionException
- If the currently logged in account does not havePermission.MESSAGE_MANAGE
in this channel.
-
crosspostMessageById
@Nonnull @CheckReturnValue default RestAction<Message> crosspostMessageById(@Nonnull java.lang.String messageId)
Attempts to crosspost the provided message.The following
ErrorResponses
are possible:ALREADY_CROSSPOSTED
The target message has already been crossposted.MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGE
in the TextChannel.UNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to crosspost- Returns:
RestAction
- Type:Message
- Throws:
java.lang.IllegalStateException
- If this channel is not a news channel. SeeisNews()
.java.lang.IllegalArgumentException
- If providedmessageId
isnull
or empty.InsufficientPermissionException
- If the currently logged in account does not havePermission.VIEW_CHANNEL
in this channel.- Since:
- 4.2.1
-
crosspostMessageById
@Nonnull @CheckReturnValue default RestAction<Message> crosspostMessageById(long messageId)
Attempts to crosspost the provided message.The following
ErrorResponses
are possible:ALREADY_CROSSPOSTED
The target message has already been crossposted.MISSING_ACCESS
The request was attempted after the account lost access to theGuild
typically due to being kicked or removed, or afterPermission.MESSAGE_READ
was revoked in theTextChannel
MISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_MANAGE
in the TextChannel.UNKNOWN_MESSAGE
The providedmessageId
is unknown in this MessageChannel, either due to the id being invalid, or the message it referred to has already been deleted.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
messageId
- The messageId to crosspost- Returns:
RestAction
- Type:Message
- Throws:
java.lang.IllegalStateException
- If this channel is not a news channel. SeeisNews()
.InsufficientPermissionException
- If the currently logged in account does not havePermission.VIEW_CHANNEL
in this channel.- Since:
- 4.2.1
-
canTalk
boolean canTalk()
Whether we can send messages in this channel.
This is an overload ofcanTalk(Member)
with the SelfMember.
Checks for bothPermission.MESSAGE_READ
andPermission.MESSAGE_WRITE
.- Returns:
- True, if we are able to read and send messages in this channel
-
canTalk
boolean canTalk(@Nonnull Member member)
Whether the specifiedMember
can send messages in this channel.
Checks for bothPermission.MESSAGE_READ
andPermission.MESSAGE_WRITE
.- Parameters:
member
- The Member to check- Returns:
- True, if the specified member is able to read and send messages in this channel
-
formatTo
default void formatTo(java.util.Formatter formatter, int flags, int width, int precision)
- Specified by:
formatTo
in interfacejava.util.Formattable
- Specified by:
formatTo
in interfaceIMentionable
- Specified by:
formatTo
in interfaceMessageChannel
-
-