Interface ThreadChannel
- All Superinterfaces:
Channel
,Comparable<GuildChannel>
,Formattable
,GuildChannel
,GuildMessageChannel
,IMemberContainer
,IMentionable
,ISnowflake
,MessageChannel
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The values permitted for the auto archive duration of aThreadChannel
. -
Method Summary
Modifier and TypeMethodDescriptiondefault RestAction<Void>
addThreadMember
(Member member) Adds a member to this thread.default RestAction<Void>
addThreadMember
(User user) Adds a member to this thread.addThreadMemberById
(long id) Adds a member to this thread.default RestAction<Void>
Adds a member to this thread.default void
The inactivity timeout of this thread.Returns theChannelManager
for this GuildChannel.int
Gets the current number of members that have joined this thread.int
Gets the current number of messages present in this thread.default Member
getOwner()
Gets theMember
that created and owns this thread.default String
Gets theUser
of the owner of this thread as a String.long
Gets the ID of the owner of this thread as a long.default ThreadMember
Gets the owner of this thread as aThreadMember
.Gets theparent channel
of this thread.default GuildMessageChannel
default ThreadMember
Gets the self member, as a member of this thread.int
The slowmode time of this thread.default ThreadMember
getThreadMember
(Member member) Gets aThreadMember
of this thread by theirMember
.default ThreadMember
getThreadMember
(User user) Gets aThreadMember
of this thread by theirMember
.getThreadMemberById
(long id) Gets aThreadMember
of this thread by theirMember
.default ThreadMember
Gets aThreadMember
of this thread by theirMember
.Gets a List of all cachedmembers
of this thread.The last time the archive info of this thread was updated.boolean
Whether this thread has been archived.boolean
Whether this thread is invitable.default boolean
isJoined()
Whether the currently logged in member has joined this thread.boolean
isLocked()
Whether this thread is locked or not.default boolean
isOwner()
Whether the current account is the owner of this thread.default boolean
isPublic()
Whether this thread is public or not.join()
Joins this thread, adding the current account to the member list of this thread.leave()
Leaves this thread, removing the current account from the member list of this thread.default RestAction<Void>
removeThreadMember
(Member member) Removes a member from this thread.default RestAction<Void>
removeThreadMember
(User user) Removes a member from this thread.removeThreadMemberById
(long id) Removes a member from this thread.default RestAction<Void>
Removes a member from this thread.default RestAction<ThreadMember>
retrieveThreadMember
(Member member) Load the thread-member for the specified user.default RestAction<ThreadMember>
retrieveThreadMember
(User user) Load the thread-member for the specified user.retrieveThreadMemberById
(long id) Load the thread-member for the user with the specified id.default RestAction<ThreadMember>
Load the thread-member for the user with the specified id.Retrieves theThreadMembers
of this thread.Methods inherited from interface net.dv8tion.jda.api.entities.Channel
getAsMention, getJDA, getName, getType
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface net.dv8tion.jda.api.entities.GuildChannel
delete, getGuild, getPermissionContainer
Methods inherited from interface net.dv8tion.jda.api.entities.GuildMessageChannel
canTalk, canTalk, clearReactionsById, clearReactionsById, clearReactionsById, clearReactionsById, clearReactionsById, clearReactionsById, deleteMessages, deleteMessagesByIds, removeReactionById, removeReactionById, removeReactionById, removeReactionById
Methods inherited from interface net.dv8tion.jda.api.entities.IMemberContainer
getMembers
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, 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
-
isPublic
default boolean isPublic()Whether this thread is public or not. Public threads can be read and joined by anyone with read access to itsparent channel
.- Returns:
- true if this thread is public, false otherwise.
-
getMessageCount
int getMessageCount()Gets the current number of messages present in this thread.
Threads started from seed messages in theparent channel
will not count that seed message.
This will be capped at 50, regardless of actual count.- Returns:
- The number of messages sent in this channel, capping at 50.
-
getMemberCount
int getMemberCount()Gets the current number of members that have joined this thread.
This is capped at 50, meaning any additional members will not affect this count.- Returns:
- The number of members that have joined this thread, capping at 50.
-
isJoined
default boolean isJoined()Whether the currently logged in member has joined this thread.- Returns:
- true if the self member has joined this thread, false otherwise.
-
isLocked
boolean isLocked()Whether this thread is locked or not. Locked threads cannot have new messages posted to them, or members join or leave them. Threads can only be locked and unlocked by moderators.- Returns:
- true if this thread is locked, false otherwise.
- See Also:
-
isInvitable
boolean isInvitable()Whether this thread is invitable.
A thread that is invitable can have non-moderators invite other non-moderators to it. A thread that is not invitable can only have moderators invite others to it.This property is exclusive to private threads.
- Returns:
- true if this thread is invitable, false otherwise.
- Throws:
UnsupportedOperationException
- If this thread is not a private thread.- See Also:
-
getParentChannel
Gets theparent channel
of this thread.- Returns:
- The parent channel of this thread.
- See Also:
-
getParentMessageChannel
Gets theparent channel
of this thread, if it is aTextChannel
orNewsChannel
.
This is a convenience method that will perform the cast if possible, throwing otherwise.- Returns:
- The parent channel of this thread, as a
GuildMessageChannel
. - Throws:
UnsupportedOperationException
- If the parent channel is not aGuildMessageChannel
.
-
getSelfThreadMember
Gets the self member, as a member of this thread.
If the current account is not a member of this thread, this will return null.- Returns:
- The self member of this thread, null if the current account is not a member of this thread.
- See Also:
-
getThreadMembers
Gets a List of all cachedmembers
of this thread.
The thread owner is not included in this list, unless the current account is the owner. Any updates to this cache are lost when JDA is shutdown, and this list is not sent to JDA on startup. For this reason,retrieveThreadMembers()
should be used instead in most cases.The cache this method relies on is empty until JDA sees a member join via a
ThreadMemberJoinEvent
.
If the current account is a member of this ThreadChannel, this cache will contain the current account, even after a restart.
In order for this cache to be updated, the following requirements must be met:- the
GatewayIntent.GUILD_MEMBERS
intent must be enabled. - the bot must be able to join the thread (either via the
MANAGE_THREADS
permission, or a public thread) - the bot must have be online to receive the update
- Returns:
- a List of all
members
of this thread. This list may be empty, but not null. - See Also:
- the
-
getThreadMember
Gets aThreadMember
of this thread by theirMember
. Note that this operation relies on theThreadMember cache
for this ThreadChannel. As the cache is likely to be unpopulated, this method is likely to return null. Use ofretrieveThreadMember(Member)
is preferred instead, once it is released.- Parameters:
member
- The member to get theThreadMember
for.- Returns:
- The
ThreadMember
of this thread for the given member. - Throws:
IllegalArgumentException
- If the given member is null.- See Also:
-
getThreadMember
Gets aThreadMember
of this thread by theirMember
. Note that this operation relies on theThreadMember cache
for this ThreadChannel. As the cache is likely to be unpopulated, this method is likely to return null. Use ofretrieveThreadMember(Member)
is preferred instead, once it is released.- Parameters:
user
- The user to get theThreadMember
for.- Returns:
- The
ThreadMember
of this thread for the given member. - Throws:
IllegalArgumentException
- If the given user is null.- See Also:
-
getThreadMemberById
Gets aThreadMember
of this thread by theirMember
. Note that this operation relies on theThreadMember cache
for this ThreadChannel. As the cache is likely to be unpopulated, this method is likely to return null. Use ofretrieveThreadMember(Member)
is preferred instead, once it is released.- Parameters:
id
- The ID of the member to get theThreadMember
for.- Returns:
- The
ThreadMember
of this thread for the given member. - Throws:
IllegalArgumentException
- If the given id is null or empty.- See Also:
-
getThreadMemberById
Gets aThreadMember
of this thread by theirMember
. Note that this operation relies on theThreadMember cache
for this ThreadChannel. As the cache is likely to be unpopulated, this method is likely to return null. Use ofretrieveThreadMember(Member)
is preferred instead, once it is released.- Parameters:
id
- The member to get theThreadMember
for.- Returns:
- The
ThreadMember
of this thread for the given member. - See Also:
-
retrieveThreadMember
@Nonnull @CheckReturnValue default RestAction<ThreadMember> retrieveThreadMember(@Nonnull Member member) Load the thread-member for the specified user.
If the thread-member is already loaded it, will be retrieved fromgetThreadMemberById(long)
and immediately provided if the thread-member information is consistent. If the bot hasn't joined the thread,GatewayIntent.GUILD_MEMBERS
is required to keep the cache updated.- Parameters:
member
- The member to load the thread-member from- Returns:
RestAction
- Type:ThreadMember
- Throws:
IllegalArgumentException
- If provided with null
-
retrieveThreadMember
@Nonnull @CheckReturnValue default RestAction<ThreadMember> retrieveThreadMember(@Nonnull User user) Load the thread-member for the specified user.
If the thread-member is already loaded, it will be retrieved fromgetThreadMemberById(long)
and immediately provided if the thread-member information is consistent. If the bot hasn't joined the thread,GatewayIntent.GUILD_MEMBERS
is required to keep the cache updated.- Parameters:
user
- The user to load the thread-member from- Returns:
RestAction
- Type:ThreadMember
- Throws:
IllegalArgumentException
- If provided with null
-
retrieveThreadMemberById
@Nonnull @CheckReturnValue default RestAction<ThreadMember> retrieveThreadMemberById(@Nonnull String id) Load the thread-member for the user with the specified id.
If the thread-member is already loaded, it will be retrieved fromgetThreadMemberById(long)
and immediately provided if the thread-member information is consistent. If the bot hasn't joined the thread,GatewayIntent.GUILD_MEMBERS
is required to keep the cache updated.- Parameters:
id
- The user id to load the thread-member from- Returns:
RestAction
- Type:ThreadMember
- Throws:
IllegalArgumentException
- If the provided id is empty or nullNumberFormatException
- If the provided id is not a snowflake
-
retrieveThreadMemberById
Load the thread-member for the user with the specified id.
If the thread-member is already loaded, it will be retrieved fromgetThreadMemberById(long)
and immediately provided if the thread-member information is consistent. If the bot hasn't joined the thread,GatewayIntent.GUILD_MEMBERS
is required to keep the cache updated.- Parameters:
id
- The user id to load the thread-member from- Returns:
RestAction
- Type:ThreadMember
-
retrieveThreadMembers
Retrieves theThreadMembers
of this thread. This requires theGatewayIntent.GUILD_MEMBERS
intent to be enabled.- Returns:
- a RestAction that resolves into a List of
ThreadMembers
of this thread.
-
isOwner
default boolean isOwner()Whether the current account is the owner of this thread.- Returns:
- true if the self account is the owner of this thread, false otherwise.
-
getOwnerIdLong
long getOwnerIdLong()Gets the ID of the owner of this thread as a long.- Returns:
- the ID of the member who created this thread as a long.
-
getOwnerId
Gets theUser
of the owner of this thread as a String.- Returns:
- The
User
of the member who created this thread as a String.
-
getOwner
Gets theMember
that created and owns this thread.
This will be null if the member is not cached, and so it is recommended toretrieve this member from the guild
usingthe owner'd ID
.- Returns:
- The
Member
of the member who created this thread. - See Also:
-
getOwnerThreadMember
Gets the owner of this thread as aThreadMember
.
This will be null if the member is not cached, and so it is recommended to retrieve the owner instead.
This method relies on thegetThreadMembers()
cache, and so it is recommended toretrieve the ThreadMember
bytheir ID
instead.- Returns:
- The owner of this thread as a
ThreadMember
. - See Also:
-
isArchived
boolean isArchived()Whether this thread has been archived. This method will consider locked channels to also be archived.Archived threads are not deleted threads, but are considered inactive. They are not shown to clients in the channels list, but can still be navigated to and read. ThreadChannels may be unarchived as long as there is space for a new active thread.
- Returns:
- true if this thread has been archived, false otherwise.
- See Also:
-
getTimeArchiveInfoLastModified
OffsetDateTime getTimeArchiveInfoLastModified()The last time the archive info of this thread was updated.This timestamp will be updated when any of the following happen:
- The channel is archived
- The channel is unarchived
- The AUTO_ARCHIVE_DURATION is changed.
- Returns:
- the time of the last archive info update.
- See Also:
-
getAutoArchiveDuration
The inactivity timeout of this thread. If a message is not sent within this amount of time, the thread will be automatically archived. A thread archived this way can be unarchived by any member.- Returns:
- the time before which a thread will automatically be archived.
- See Also:
-
getSlowmode
int getSlowmode()The slowmode time of this thread. This determines the time each non-moderator must wait before sending another message.- Returns:
- The amount of time in seconds a ThreadMember must wait between sending messages.
- See Also:
-
join
Joins this thread, adding the current account to the member list of this thread. Note that joining threads is not a requirement of getting events about the thread.
This will have no effect if the current account is already a member of this thread.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 after access was lost to this ThreadChannel (either by losing access to the parent of a public ThreadChannel, or losingMANAGE_THREADS
to a private channel).UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.
-
leave
Leaves this thread, removing the current account from the member list of this thread.
This will have no effect if the current account is not a member of this thread.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.UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.
-
addThreadMemberById
Adds a member to this thread.
This will have no effect if the member is already a member of this thread.The following
ErrorResponses
are possible:MISSING_ACCESS
This can be caused by any of the following:- The request was attempted after the account lost access to the
Guild
, typically due to being kicked or removed. - The user supplied is not a member of this ThreadChannel's
Guild
- The thread is not
invitable
, and the current account does not have theMANAGE_THREADS
permission.
- The request was attempted after the account lost access to the
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.UNKNOWN_USER
The provided User ID does not belong to a user.INVALID_FORM_BODY
The provided User ID is not a valid snowflake.
- Parameters:
id
- The id of the member to add.- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.
-
addThreadMemberById
Adds a member to this thread.
This will have no effect if the member is already a member of this thread.The following
ErrorResponses
are possible:MISSING_ACCESS
This can be caused by any of the following:- The request was attempted after the account lost access to the
Guild
, typically due to being kicked or removed. - The user supplied is not a member of this ThreadChannel's
Guild
- The thread is not
invitable
, and the current account does not have theMANAGE_THREADS
permission.
- The request was attempted after the account lost access to the
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.UNKNOWN_USER
The provided User ID does not belong to a user.INVALID_FORM_BODY
The provided User ID is not a valid snowflake.
- Parameters:
id
- The id of the member to add.- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.NumberFormatException
- If the provided id is not a valid snowflake.
-
addThreadMember
Adds a member to this thread.
This will have no effect if the member is already a member of this thread.The following
ErrorResponses
are possible:MISSING_ACCESS
This can be caused by any of the following:- The request was attempted after the account lost access to the
Guild
, typically due to being kicked or removed. - The user supplied is not a member of this ThreadChannel's
Guild
- The thread is not
invitable
, and the current account does not have theMANAGE_THREADS
permission.
- The request was attempted after the account lost access to the
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
user
- TheUser
to add.- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.IllegalArgumentException
- If the provided user was null.
-
addThreadMember
Adds a member to this thread.
This will have no effect if the member is already a member of this thread.The following
ErrorResponses
are possible:MISSING_ACCESS
This can be caused by any of the following:- The request was attempted after the account lost access to the
Guild
, typically due to being kicked or removed. - The user supplied is not a member of this ThreadChannel's
Guild
- The thread is not
invitable
, and the current account does not have theMANAGE_THREADS
permission.
- The request was attempted after the account lost access to the
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
member
- TheMember
to add.- Returns:
RestAction
- Throws:
IllegalStateException
- If this thread is locked or archived.IllegalArgumentException
- If the provided member was null.
-
removeThreadMemberById
Removes a member from this thread.Removing members from threads requires the
Permission.MANAGE_THREADS
permission unless the thread is private and owned by the current account.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 the bot losing permissions to perform this action.
This can also be caused if the user supplied is not a member of this ThreadChannel'sGuild
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.UNKNOWN_USER
The provided User ID does not belong to a user.INVALID_FORM_BODY
The provided User ID is not a valid snowflake.
- Parameters:
id
- The id of the member to remove from this thread.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the account does not have thePermission.MANAGE_THREADS
permission, and this isn't a private thread channel this account owns.
-
removeThreadMemberById
Removes a member from this thread.Removing members from threads requires the
Permission.MANAGE_THREADS
permission unless the thread is private and owned by the current account.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 the bot losing permissions to perform this action.
This can also be caused if the user supplied is not a member of this ThreadChannel'sGuild
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.UNKNOWN_USER
The provided User ID does not belong to a user.INVALID_FORM_BODY
The provided User ID is not a valid snowflake.
- Parameters:
id
- The id of the member to remove from this thread.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the account does not have thePermission.MANAGE_THREADS
permission, and this isn't a private thread channel this account owns.NumberFormatException
- If the provided id is not a valid snowflake.
-
removeThreadMember
Removes a member from this thread.Removing members from threads requires the
Permission.MANAGE_THREADS
permission unless the thread is private and owned by the current account.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 the bot losing permissions to perform this action.
This can also be caused if the user supplied is not a member of this ThreadChannel'sGuild
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
- Parameters:
user
- The user to remove from this thread.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the account does not have thePermission.MANAGE_THREADS
permission, and this isn't a private thread channel this account owns.IllegalArgumentException
- If the provided user was null.
-
removeThreadMember
Removes a member from this thread.Removing members from threads requires the
Permission.MANAGE_THREADS
permission unless the thread is private and owned by the current account.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 the bot losing permissions to perform this action.
This can also be caused if the member supplied is not a member of this ThreadChannel'sGuild
UNKNOWN_CHANNEL
The request was attempted after the channel was deleted.
Removing members from public threads or private threads this account does not own requires the
Permission.MANAGE_THREADS
permission.- Parameters:
member
- The member to remove from this thread.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the account does not have thePermission.MANAGE_THREADS
permission, and this isn't a private thread channel this account owns.IllegalArgumentException
- If the provided member was null.
-
getManager
Description copied from interface:GuildChannel
Returns theChannelManager
for this GuildChannel.
In the ChannelManager, you can modify the name, topic and position of this GuildChannel. You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.This is a lazy idempotent getter. The manager is retained after the first call. This getter is not thread-safe and would require guards by the user.
- Specified by:
getManager
in interfaceGuildChannel
- Returns:
- The ChannelManager of this GuildChannel
-
formatTo
- Specified by:
formatTo
in interfaceChannel
- Specified by:
formatTo
in interfaceFormattable
- Specified by:
formatTo
in interfaceIMentionable
-