Interface GuildMessageChannel
- All Superinterfaces:
Channel,Comparable<GuildChannel>,Formattable,GuildChannel,IMentionable,ISnowflake,MessageChannel
- All Known Subinterfaces:
BaseGuildMessageChannel,NewsChannel,TextChannel,ThreadChannel
BaseGuildMessageChannel, such as ThreadChannel.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanTalk()Whether the currently logged in user can send messages in this channel or not.booleanWhether the specifiedMembercan send messages in this channel.default RestAction<Void>clearReactionsById(long messageId) Attempts to remove all reactions from a message with the specifiedmessageIdin this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.default RestAction<Void>clearReactionsById(long messageId, String unicode) Removes all reactions for the specified emoji.default RestAction<Void>clearReactionsById(long messageId, Emote emote) Removes all reactions for the specified emoji.clearReactionsById(String messageId) Attempts to remove all reactions from a message with the specifiedmessageIdin this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.clearReactionsById(String messageId, String unicode) Removes all reactions for the specified emoji.default RestAction<Void>clearReactionsById(String messageId, Emote emote) Removes all reactions for the specified emoji.default RestAction<Void>deleteMessages(Collection<Message> messages) Bulk deletes a list of messages.deleteMessagesByIds(Collection<String> messageIds) Bulk deletes a list of messages.default RestAction<Void>removeReactionById(long messageId, String unicode, User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>removeReactionById(long messageId, Emote emote, User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.removeReactionById(String messageId, String unicode, User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.default RestAction<Void>removeReactionById(String messageId, Emote emote, User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.Methods inherited from interface net.dv8tion.jda.api.entities.Channel
formatTo, getAsMention, getJDA, getName, getTypeMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface net.dv8tion.jda.api.entities.GuildChannel
delete, getGuild, getManager, getPermissionContainerMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreatedMethods inherited from interface net.dv8tion.jda.api.entities.MessageChannel
addReactionById, addReactionById, addReactionById, addReactionById, deleteMessageById, deleteMessageById, 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, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendTyping, unpinMessageById, unpinMessageById
-
Method Details
-
canTalk
default boolean canTalk()Description copied from interface:MessageChannelWhether the currently logged in user can send messages in this channel or not.
ForGuildMessageChannelthis method checks for bothPermission.VIEW_CHANNELandPermission.MESSAGE_SEND.
ForThreadChannelthis method checks forPermission.MESSAGE_SEND_IN_THREADSinstead ofPermission.MESSAGE_SEND.
ForPrivateChannelthis method checks if the user that this PrivateChannel communicates with is not a bot, but it does not check if the said user blocked the currently logged in user or have their DMs disabled.- Specified by:
canTalkin interfaceMessageChannel- Returns:
- True, if we are able to read and send messages in this channel
-
canTalk
Whether the specifiedMembercan send messages in this channel.
Checks for bothPermission.VIEW_CHANNELandPermission.MESSAGE_SEND.- Parameters:
member- The Member to check- Returns:
- True, if the specified member is able to read and send messages in this channel
-
removeReactionById
@Nonnull @CheckReturnValue RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull String unicode, @Nonnull User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin 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 providedmessageIdis 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:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
unicodeisnullor empty.
- If provided
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(long messageId, @Nonnull String unicode, @Nonnull User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin 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
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin 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 providedmessageIdis 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:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
unicodeisnullor empty.
- If provided
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull Emote emote, @Nonnull User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin 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 providedmessageIdis 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:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
emoteisnull.
- If provided
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin this channel.
-
removeReactionById
@Nonnull @CheckReturnValue default RestAction<Void> removeReactionById(long messageId, @Nonnull Emote emote, @Nonnull User user) Attempts to remove the reaction from a message represented by the specifiedmessageIdin this MessageChannel.An Emote is not the same as an emoji!
Emotes are custom guild-specific images unlike global unicode emojis!The following
ErrorResponsesare possible:MISSING_ACCESS
The request was attempted after the account lost access to theGuildtypically due to being kicked or removed, or afterPermission.VIEW_CHANNELwas revoked in theTextChannel
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin 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 providedmessageIdis 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:
IllegalArgumentException-- If provided
messageIdisnullor empty. - If provided
emoteisnull.
- If provided
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin this channel.
-
deleteMessages
@Nonnull @CheckReturnValue default RestAction<Void> deleteMessages(@Nonnull 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_MANAGEin this channel to use this function.This method is best used when using
MessageHistoryto 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_MANAGEin the channel.
- Parameters:
messages- The collection of messages to delete.- Returns:
AuditableRestAction- Throws:
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
@Nonnull @CheckReturnValue RestAction<Void> deleteMessagesByIds(@Nonnull Collection<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_MANAGEin 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
MessageHistoryor haveMessageobjects, 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_MANAGEin the channel.
- Parameters:
messageIds- The message ids for the messages to delete.- Returns:
AuditableRestAction- Throws:
IllegalArgumentException- If the size of the list less than 2 or more than 100 messages.NumberFormatException- If any of the provided ids cannot be parsed byLong.parseLong(String)InsufficientPermissionException- If this account does not havePermission.MESSAGE_MANAGE- See Also:
-
clearReactionsById
Attempts to remove all reactions from a message with the specifiedmessageIdin this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.The following
ErrorResponsesare possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The clear-reactions request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen adding the reaction.UNKNOWN_MESSAGEThe 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_MANAGEin this channel.IllegalArgumentException- If the providedidisnullor empty.
-
clearReactionsById
Attempts to remove all reactions from a message with the specifiedmessageIdin this TextChannel
This is useful for moderator commands that wish to remove all reactions at once from a specific message.The following
ErrorResponsesare possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChanneldue toPermission.VIEW_CHANNELbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The clear-reactions request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen adding the reaction.UNKNOWN_MESSAGEThe 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_MANAGEin this channel.
-
clearReactionsById
@Nonnull @CheckReturnValue RestAction<Void> clearReactionsById(@Nonnull String messageId, @Nonnull 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
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_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_MANAGEin the channelIllegalArgumentException- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<Void> clearReactionsById(@Nonnull String messageId, @Nonnull Emote emote) Removes all reactions for the specified emoji.The following
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_EMOJI
The providedEmotewas deleted or doesn't exist.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId- The id for the target messageemote- TheEmoteto remove reactions for- Returns:
RestAction- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin the channelIllegalArgumentException- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<Void> clearReactionsById(long messageId, @Nonnull 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
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_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_MANAGEin the channelIllegalArgumentException- If provided with null- Since:
- 4.2.0
-
clearReactionsById
@Nonnull @CheckReturnValue default RestAction<Void> clearReactionsById(long messageId, @Nonnull Emote emote) Removes all reactions for the specified emoji.The following
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_EMOJI
The providedEmotewas deleted or doesn't exist.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
messageId- The id for the target messageemote- TheEmoteto remove reactions for- Returns:
RestAction- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin the channelIllegalArgumentException- If provided with null- Since:
- 4.2.0
-