diff --git a/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java b/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java index 5b4bfc18af..c124412d32 100644 --- a/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java +++ b/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java @@ -16,9 +16,16 @@ package net.dv8tion.jda.api.audit; +import net.dv8tion.jda.annotations.DeprecatedSince; +import net.dv8tion.jda.annotations.ForRemoval; +import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.channel.Channel; import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.channel.attribute.ICategorizableChannel; +import net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel; +import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; +import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; @@ -207,6 +214,13 @@ public enum AuditLogKey */ CHANNEL_NAME("name"), + /** + * Change of the {@link Channel#getFlags() flags} value. + * + *
Expected type: Integer
+ */
+ CHANNEL_FLAGS("flags"),
+
/**
* Change of the {@link ICategorizableChannel#getParentCategory()} ICategorizable.getParentCategory()} value.
*
Use with {@link net.dv8tion.jda.api.entities.Guild#getCategoryById(String) Guild.getCategoryById(String)}
@@ -224,13 +238,26 @@ public enum AuditLogKey
CHANNEL_TOPIC("topic"),
/**
- * Change of the {@link TextChannel#getSlowmode() TextChannel.getSlowmode()} value.
- *
Only for {@link ChannelType#TEXT ChannelType.TEXT}
+ * Change of the {@link ISlowmodeChannel#getSlowmode()} value.
*
*
Expected type: Integer */ CHANNEL_SLOWMODE("rate_limit_per_user"), + /** + * Change of the {@link IThreadContainer#getDefaultThreadSlowmode()} value. + * + *
Expected type: Integer + */ + CHANNEL_DEFAULT_THREAD_SLOWMODE("default_thread_rate_limit_per_user"), + + /** + * Change of the {@link ForumChannel#getDefaultReaction()} value. + * + *
Expected type: Map containing {@code emoji_id} and {@code emoji_name}
+ */
+ CHANNEL_DEFAULT_REACTION_EMOJI("default_reaction_emoji"),
+
/**
* Change of the {@link VoiceChannel#getBitrate() VoiceChannel.getBitrate()} value.
*
Only for {@link ChannelType#VOICE ChannelType.VOICE}
@@ -277,6 +304,21 @@ public enum AuditLogKey
*/
CHANNEL_OVERRIDES("permission_overwrites"),
+ /**
+ * The available tags of this {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannel}.
+ *
+ *
Expected type: List{@literal
+ */
+ CHANNEL_AVAILABLE_TAGS("available_tags"),
+
+ /**
+ * The {@link ForumChannel#getDefaultSortOrder()} value.
+ *
Only for {@link ChannelType#FORUM}.
+ *
+ *
Expected type: Integer + */ + CHANNEL_DEFAULT_SORT_ORDER("default_sort_order"), + // THREADS /** @@ -287,10 +329,16 @@ public enum AuditLogKey THREAD_NAME("name"), /** - * Change of the {@link ThreadChannel#getSlowmode() ThreadChannel.getSlowmode()} value. + * Change of the {@link ISlowmodeChannel#getSlowmode()} value. * *
Expected type: Integer + * + * @deprecated Use {@link #CHANNEL_SLOWMODE} instead */ + @Deprecated + @ForRemoval + @DeprecatedSince("5.0.0") + @ReplaceWith("CHANNEL_SLOWMODE") THREAD_SLOWMODE("rate_limit_per_user"), /** @@ -322,6 +370,13 @@ public enum AuditLogKey */ THREAD_INVITABLE("invitable"), + /** + * The applied tags of this {@link ThreadChannel}, given that it is a forum post. + * + *
Expected type: List{@literal The returned list is ordered in the same fashion as it would be by the official discord client.
* The returned list is ordered in the same fashion as it would be by the official discord client.
* Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
+ * the returned {@link RestAction RestAction} include the following:
+ * Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
+ * the returned {@link RestAction RestAction} include the following:
+ * Limited to {@link net.dv8tion.jda.api.entities.channel.attribute.ICategorizableChannel Categorizable Channels} (and implementations).
*
* @see net.dv8tion.jda.api.entities.channel.attribute.ICategorizableChannel#getParentCategory()
*/
@@ -74,13 +84,26 @@ public enum ChannelField
*/
POSITION("position", null), //Discord doesn't track Channel position changes in AuditLog.
+ /**
+ * The default slowmode applied to threads in a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer ThreadContainer}.
+ *
+ * @see IThreadContainer#getDefaultThreadSlowmode()
+ */
+ DEFAULT_THREAD_SLOWMODE("default_thread_slowmode", AuditLogKey.CHANNEL_DEFAULT_THREAD_SLOWMODE),
+
+ /**
+ * The default reaction emoji used in a {@link ForumChannel}.
+ *
+ * @see ForumChannel#getDefaultReaction()
+ */
+ DEFAULT_REACTION_EMOJI("default_reaction_emoji", AuditLogKey.CHANNEL_DEFAULT_REACTION_EMOJI),
//Text Specific
/**
* The topic of the channel.
*
- * Limited to {@link NewsChannel NewsChannels} and {@link TextChannel TextChannels}.
+ * Limited to {@link NewsChannel NewsChannels} and {@link TextChannel TextChannels}.
*
* @see StandardGuildMessageChannel#getTopic()
*/
@@ -89,34 +112,42 @@ public enum ChannelField
/**
* The NSFW state of the channel.
*
- * Limited to {@link StandardGuildMessageChannel StandardGuildMessageChannels} (and implementations).
+ * Limited to {@link IAgeRestrictedChannel IAgeRestrictedChannels} (and implementations).
*
- * @see StandardGuildMessageChannel#isNSFW()
+ * @see IAgeRestrictedChannel#isNSFW()
*/
NSFW("nsfw", AuditLogKey.CHANNEL_NSFW),
/**
- * The state of slow mode in the channel. This defines the minimum time between message sends.
+ * The state of slow mode in the channel.
+ * Limited to {@link ISlowmodeChannel ISlowmodeChannels} (and implementations).
*
- * @see TextChannel#getSlowmode()
+ * @see ISlowmodeChannel#getSlowmode()
*/
SLOWMODE("slowmode", AuditLogKey.CHANNEL_SLOWMODE),
+ /**
+ * The applied tags of a {@link ForumChannel}.
+ *
+ * @see ForumChannel#getAvailableTags()
+ */
+ AVAILABLE_TAGS("available_tags", AuditLogKey.CHANNEL_AVAILABLE_TAGS),
+
//Voice Specific
/**
* The bitrate (in bits per second) of the audio in this channel.
*
- * For standard channels this is between 8000 and 96000.
+ * For standard channels this is between 8000 and 96000.
*
- * VIP servers extend this limit to 128000.
+ * VIP servers extend this limit to 128000.
* Limited to {@link AudioChannel Audio Channels}.
*
* @see AudioChannel#getBitrate()
*/
@@ -125,7 +156,7 @@ public enum ChannelField
/**
* The region of the channel.
*
- * Limited to {@link AudioChannel Audio Channels}.
+ * Limited to {@link AudioChannel Audio Channels}.
*
* @see AudioChannel#getRegion()
* @see net.dv8tion.jda.api.Region
@@ -135,7 +166,7 @@ public enum ChannelField
/**
* The maximum user count of this channel.
*
- * Limited to {@link VoiceChannel Voice Channels}.
+ * Limited to {@link VoiceChannel Voice Channels}.
*
* @see VoiceChannel#getUserLimit()
*/
@@ -147,9 +178,9 @@ public enum ChannelField
/**
* The auto archive duration of this channel.
*
- * If the thread is inactive for this long, it becomes auto-archived.
+ * If the thread is inactive for this long, it becomes auto-archived.
*
- * Limited to {@link ThreadChannel Thread Channels}.
+ * Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#getAutoArchiveDuration()
* @see ThreadChannel.AutoArchiveDuration
@@ -159,9 +190,9 @@ public enum ChannelField
/**
* The archive state of this channel.
*
- * If the channel is archived, this is true.
+ * If the channel is archived, this is true.
*
- * Limited to {@link ThreadChannel Thread Channels}.
+ * Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#isArchived()
*/
@@ -170,7 +201,7 @@ public enum ChannelField
/**
* The time this channel's archival information was last updated.
*
- * This timestamp will be updated when any of the following happen:
+ * This timestamp will be updated when any of the following happen:
* If the channel is locked, this is true.
*
- * Limited to {@link ThreadChannel Thread Channels}.
+ * Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#isLocked()
*/
@@ -198,14 +228,31 @@ public enum ChannelField
/**
* The invite state of this channel.
*
- * If the channel is invitable, this is true.
+ * If the channel is invitable, this is true.
*
- * Limited to {@link ThreadChannel Thread Channels}.
+ * Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#isInvitable()
*/
- INVITABLE("invitable", AuditLogKey.THREAD_INVITABLE)
- ;
+ INVITABLE("invitable", AuditLogKey.THREAD_INVITABLE),
+
+ /**
+ * The tags applied to a forum post thread.
+ *
+ * Limited to {@link ThreadChannel ThreadChannels} inside {@link ForumChannel ForumChannels}
+ *
+ * @see ThreadChannel#getAppliedTags()
+ */
+ APPLIED_TAGS("applied_tags", AuditLogKey.THREAD_APPLIED_TAGS),
+
+ /**
+ * The default sort order of a forum channel.
+ *
+ * Limited to {@link ForumChannel Forum Channels}.
+ *
+ * @see ForumChannel#getDefaultSortOrder()
+ */
+ DEFAULT_SORT_ORDER("default_sort_order", AuditLogKey.CHANNEL_DEFAULT_SORT_ORDER);
private final String fieldName;
private final AuditLogKey auditLogKey;
@@ -228,6 +275,8 @@ public AuditLogKey getAuditLogKey()
return auditLogKey;
}
+ @Nonnull
+ @Override
public String toString()
{
return "ChannelField." + name() + '(' + fieldName + ')';
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/ChannelFlag.java b/src/main/java/net/dv8tion/jda/api/entities/channel/ChannelFlag.java
new file mode 100644
index 0000000000..a807d7174e
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/ChannelFlag.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel;
+
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
+import net.dv8tion.jda.internal.utils.Checks;
+
+import javax.annotation.Nonnull;
+import java.util.Collection;
+import java.util.EnumSet;
+
+/**
+ * Flags for specific channel settings.
+ */
+public enum ChannelFlag
+{
+ /**
+ * This is a forum post {@link ThreadChannel} which is pinned in the {@link ForumChannel}.
+ */
+ PINNED(1 << 1),
+ /**
+ * This is a {@link ForumChannel} which requires all new post threads to have at least one applied tag.
+ */
+ REQUIRE_TAG(1 << 4);
+
+ private final int value;
+
+ ChannelFlag(int value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * The raw bitset value of this flag.
+ *
+ * @return The raw value
+ */
+ public int getRaw()
+ {
+ return value;
+ }
+
+ /**
+ * Parses the provided bitset to the corresponding enum constants.
+ *
+ * @param bitset
+ * The bitset of channel flags
+ *
+ * @return The enum constants of the provided bitset
+ */
+ @Nonnull
+ public static EnumSet This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
+ * For {@link Guild}, {@link JDA}, or {@link ShardManager},
+ * this returns the relevant channel with respect to the cache within each of those objects.
+ * For a guild, this would mean it only returns channels within the same guild.
+ * This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
+ * For {@link Guild}, {@link JDA}, or {@link ShardManager},
+ * this returns the relevant channel with respect to the cache within each of those objects.
+ * For a guild, this would mean it only returns channels within the same guild.
+ * This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
+ * For {@link Guild}, {@link JDA}, or {@link ShardManager},
+ * this returns the relevant channel with respect to the cache within each of those objects.
+ * For a guild, this would mean it only returns channels within the same guild.
+ * This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
+ * For {@link Guild}, {@link JDA}, or {@link ShardManager},
+ * this returns the relevant channel with respect to the cache within each of those objects.
+ * For a guild, this would mean it only returns channels within the same guild.
+ * This copies the backing store into a list. This means every call
+ * creates a new list with O(n) complexity. It is recommended to store this into
+ * a local variable or use {@link #getForumChannelCache()} and use its more efficient
+ * versions of handling these values.
+ *
+ * This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
+ * For {@link Guild}, {@link JDA}, or {@link ShardManager},
+ * this returns the relevant channel with respect to the cache within each of those objects.
+ * For a guild, this would mean it only returns channels within the same guild.
+ * Note bots are unaffected by this.
+ * Special case The resulting {@link ThreadChannel ThreadChannel} may be either one of:
* The resulting {@link ThreadChannel ThreadChannel} may be one of:
* The resulting {@link ThreadChannel ThreadChannel} may be one of:
* The resulting {@link ThreadChannel ThreadChannel} may be one of:
* You can use {@link #retrieveArchivedPrivateThreadChannels()}, to get all private archived threads.
+ *
+ * @throws InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} in this channel
+ *
+ * @return {@link ThreadChannelPaginationAction} to iterate over all public archived ThreadChannels
+ */
@Nonnull
@CheckReturnValue
ThreadChannelPaginationAction retrieveArchivedPublicThreadChannels();
- //TODO-v5: Docs
+ /**
+ * Retrieves the archived private {@link ThreadChannel ThreadChannels} for this channel.
+ * You can use {@link #retrieveArchivedPublicThreadChannels()}, to get all public archived threads.
+ *
+ * Note that {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels} cannot have private threads.
+ *
+ * @throws InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}
+ * or {@link net.dv8tion.jda.api.Permission#MANAGE_THREADS Permission.MANAGE_THREADS} in this channel
+ *
+ * @return {@link ThreadChannelPaginationAction} to iterate over all private archived ThreadChannels
+ */
@Nonnull
@CheckReturnValue
ThreadChannelPaginationAction retrieveArchivedPrivateThreadChannels();
- //TODO-v5: Docs
+ /**
+ * Retrieves the archived private {@link ThreadChannel ThreadChannels} for this channel, that the bot has previously joined or been added to.
+ * You can use {@link #retrieveArchivedPrivateThreadChannels()}, to get all private archived threads.
+ *
+ * Note that {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels} cannot have private threads.
+ *
+ * @throws InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY} in this channel
+ *
+ * @return {@link ThreadChannelPaginationAction} to iterate over all joined private archived ThreadChannels
+ */
@Nonnull
@CheckReturnValue
ThreadChannelPaginationAction retrieveArchivedPrivateJoinedThreadChannels();
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/Category.java b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/Category.java
index d42a9112d3..1a9e78ce21 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/Category.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/Category.java
@@ -20,6 +20,7 @@
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.IPermissionHolder;
import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.channel.Channel;
import net.dv8tion.jda.api.entities.channel.attribute.ICopyableChannel;
import net.dv8tion.jda.api.entities.channel.attribute.IMemberContainer;
import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer;
@@ -57,10 +58,8 @@
public interface Category extends GuildChannel, ICopyableChannel, IPositionableChannel, IPermissionContainer, IMemberContainer
{
/**
- * All {@link GuildChannel Channels} listed
- * for this Category
- * This will copy all {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverrides} of this Category!
+ * Unless the bot is unable to sync it with this category due to permission escalation.
+ * See {@link IPermissionHolder#canSync(IPermissionContainer, IPermissionContainer)} for details.
+ *
+ * Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
+ * the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
+ * This will copy all {@link net.dv8tion.jda.api.entities.PermissionOverride PermissionOverrides} of this Category!
+ * Unless the bot is unable to sync it with this category due to permission escalation.
+ * See {@link IPermissionHolder#canSync(IPermissionContainer, IPermissionContainer)} for details.
+ *
+ * Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
+ * the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
+ * The {@code CREATE POSTS} permission that is shown in the official Discord Client, is an alias for {@link net.dv8tion.jda.api.Permission#MESSAGE_SEND Permission.MESSAGE_SEND}.
+ * {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS Permission.CREATE_PUBLIC_THREADS} is ignored for creating forum posts.
+ *
+ * @see Guild#createForumChannel(String, Category)
+ * @see #createForumPost(String, MessageCreateData)
+ */
+public interface ForumChannel extends StandardGuildChannel, IThreadContainer, IWebhookContainer, IAgeRestrictedChannel, ISlowmodeChannel
+{
+ /**
+ * The maximum length of a forum topic ({@value #MAX_FORUM_TOPIC_LENGTH})
+ */
+ int MAX_FORUM_TOPIC_LENGTH = 4096;
+ /**
+ * The maximum number of {@link ForumPostAction#setTags(Collection) tags} that can be applied to a forum post. ({@value #MAX_POST_TAGS})
+ */
+ int MAX_POST_TAGS = 5;
+
+ @Nonnull
+ @Override
+ default ChannelType getType()
+ {
+ return ChannelType.FORUM;
+ }
+
+ @Nonnull
+ @Override
+ ForumChannelManager getManager();
+
+ @Nonnull
+ @Override
+ ChannelAction This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return {@link SortedSnowflakeCacheView} of {@link ForumTag}
+ */
+ @Nonnull
+ SortedSnowflakeCacheView This is a shortcut for {@link #getAvailableTagCache() getAvailableTagCache().asList()}.
+ * This method will copy the underlying cache into the list, running in {@code O(n)} time.
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return Immutable {@link List} of {@link ForumTag}
+ */
+ @Nonnull
+ default List This is a shortcut for {@link #getAvailableTagCache() getAvailableTagCache().getElementsByName(name, ignoreCase)}.
+ * This method will copy the underlying cache into the list, running in {@code O(n)} time.
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @param name
+ * The name of the tag
+ * @param ignoreCase
+ * Whether to use {@link String#equalsIgnoreCase(String)}
+ *
+ * @throws IllegalArgumentException
+ * If the name is {@code null}
+ *
+ * @return Immutable {@link List} of {@link ForumTag} with the given name
+ */
+ @Nonnull
+ default List This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @param id
+ * The tag id
+ *
+ * @return The tag for the provided id, or {@code null} if no tag with that id exists
+ *
+ * @see net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake#fromId(long)
+ */
+ @Nullable
+ default ForumTag getAvailableTagById(long id)
+ {
+ return getAvailableTagCache().getElementById(id);
+ }
+
+ /**
+ * Retrieves the tag for the provided id.
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @param id
+ * The tag id
+ *
+ * @throws IllegalArgumentException
+ * If the provided id is null
+ * @throws NumberFormatException
+ * If the provided id is not a valid snowflake
+ *
+ * @return The tag for the provided id, or {@code null} if no tag with that id exists
+ *
+ * @see net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake#fromId(String)
+ */
+ @Nullable
+ default ForumTag getAvailableTagById(@Nonnull String id)
+ {
+ return getAvailableTagCache().getElementById(id);
+ }
+
+ /**
+ * The topic set for this channel, this is referred to as Guidelines in the official Discord client.
+ * Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} include:
+ * Note bots are unaffected by this.
- * This includes all thread channel types, namely:
+ * When a thread channel is {@link #isArchived() archived}, no new members can be added.
+ * You can use the {@link #getManager() manager} to {@link ThreadChannelManager#setArchived(boolean) unarchive} the thread.
+ *
+ * @see Guild#getThreadChannels()
+ * @see Guild#getThreadChannelById(long)
+ * @see Guild#getThreadChannelCache()
+ */
+public interface ThreadChannel extends GuildMessageChannel, IMemberContainer, ISlowmodeChannel
{
- //TODO fields that need to be researched:
- // - rate_limit_per_user
- // - last_pin_timestamp (do we even use this for Text/News channels?)
-
/**
* Whether this thread is public or not.
*
- * Public threads can be read and joined by anyone with read access to its {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer parent channel}.
+ * Public threads can be read and joined by anyone with read access to its {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer parent channel}.
*
* @return true if this thread is public, false otherwise.
*/
@@ -58,19 +74,24 @@ default boolean isPublic()
/**
* Gets the current number of messages present in this thread.
- * Locked threads cannot have new messages posted to them, or members join or leave them.
* Threads can only be locked and unlocked by moderators.
*
* @return true if this thread is locked, false otherwise.
*
- * @see ChannelField#LOCKED
+ * @see ChannelField#LOCKED
*/
boolean isLocked();
@@ -113,41 +134,57 @@ default boolean isJoined()
*
* @return true if this thread is invitable, false otherwise.
*
- * @see ChannelField#INVITABLE
+ * @see ChannelField#INVITABLE
*/
boolean isInvitable();
/**
- * Gets the {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer parent channel} of this thread.
+ * Whether this thread is a pinned forum post.
*
- * @see net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer#getThreadChannels()
+ * @return True, if this is a pinned forum post.
+ */
+ default boolean isPinned()
+ {
+ return getFlags().contains(ChannelFlag.PINNED);
+ }
+
+ /**
+ * Gets the {@link IThreadContainer parent channel} of this thread.
*
* @return The parent channel of this thread.
+ *
+ * @see IThreadContainer#getThreadChannels()
*/
@Nonnull
IThreadContainerUnion getParentChannel();
- //todo-v5: document additional subclasses of GuildMessageChannel (VoiceChannels and ForumChannels, when needed)
/**
- * Gets the {@link GuildMessageChannel parent channel} of this thread, if it is a {@link TextChannel} or {@link NewsChannel}.
- * If the current account is not a member of this thread, this will return null.
*
* @return The self member of this thread, null if the current account is not a member of this thread.
*
- * @see #isJoined()
+ * @see #isJoined()
*/
@Nullable
default ThreadMember getSelfThreadMember()
@@ -207,8 +244,8 @@ default ThreadMember getSelfThreadMember()
/**
* Gets a List of all cached {@link ThreadMember members} 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, {@link #retrieveThreadMembers()} should be used instead in most cases.
*
@@ -221,9 +258,9 @@ default ThreadMember getSelfThreadMember()
* Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
* As the cache is likely to be unpopulated, this method is likely to return null.
*
- * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
- *
- * @param member
- * The member to get the {@link ThreadMember} for.
+ * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
*
- * @return The {@link ThreadMember} of this thread for the given member.
+ * @param member
+ * The member to get the {@link ThreadMember} for.
*
* @throws IllegalArgumentException
* If the given member is null.
*
- * @see #retrieveThreadMember(Member)
+ * @return The {@link ThreadMember} of this thread for the given member.
+ *
+ * @see #retrieveThreadMember(Member)
*/
@Nullable
default ThreadMember getThreadMember(Member member)
@@ -256,20 +293,20 @@ default ThreadMember getThreadMember(Member member)
/**
* Gets a {@link ThreadMember} of this thread by their {@link Member}.
*
- * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
+ * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
* As the cache is likely to be unpopulated, this method is likely to return null.
*
- * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
+ * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
*
- * @param user
- * The user to get the {@link ThreadMember} for.
- *
- * @return The {@link ThreadMember} of this thread for the given member.
+ * @param user
+ * The user to get the {@link ThreadMember} for.
*
* @throws IllegalArgumentException
* If the given user is null.
*
- * @see #retrieveThreadMember(Member)
+ * @return The {@link ThreadMember} of this thread for the given member.
+ *
+ * @see #retrieveThreadMember(Member)
*/
@Nullable
default ThreadMember getThreadMember(User user)
@@ -281,20 +318,20 @@ default ThreadMember getThreadMember(User user)
/**
* Gets a {@link ThreadMember} of this thread by their {@link Member}.
*
- * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
+ * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
* As the cache is likely to be unpopulated, this method is likely to return null.
*
- * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
+ * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
*
* @param id
* The ID of the member to get the {@link ThreadMember} for.
*
- * @return The {@link ThreadMember} of this thread for the given member.
- *
* @throws IllegalArgumentException
* If the given id is null or empty.
*
- * @see #retrieveThreadMember(Member)
+ * @return The {@link ThreadMember} of this thread for the given member.
+ *
+ * @see #retrieveThreadMember(Member)
*/
@Nullable
default ThreadMember getThreadMemberById(String id)
@@ -305,17 +342,17 @@ default ThreadMember getThreadMemberById(String id)
/**
* Gets a {@link ThreadMember} of this thread by their {@link Member}.
*
- * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
+ * Note that this operation relies on the {@link #getThreadMembers() ThreadMember cache} for this ThreadChannel.
* As the cache is likely to be unpopulated, this method is likely to return null.
*
- * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
+ * Use of {@link #retrieveThreadMember(Member)} is preferred instead, once it is released.
*
* @param id
* The member to get the {@link ThreadMember} for.
*
* @return The {@link ThreadMember} of this thread for the given member.
*
- * @see #retrieveThreadMember(Member)
+ * @see #retrieveThreadMember(Member)
*/
@Nullable
ThreadMember getThreadMemberById(long id);
@@ -405,7 +442,7 @@ default CacheRestAction This requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_MEMBERS} intent to be enabled.
*
* @return a RestAction that resolves into a List of {@link ThreadMember ThreadMembers} of this thread.
*/
@@ -443,13 +480,14 @@ default String getOwnerId()
/**
* Gets the {@link Member} that created and owns this thread.
- * This method relies on the {@link #getThreadMembers()} cache,
+ * and so it is recommended to {@link #retrieveThreadMemberById(long) retrieve the ThreadMember}
+ * by {@link #getOwnerIdLong() their ID} instead.
*
* @return The owner of this thread as a {@link ThreadMember}.
*
- * @see #getThreadMemberById(long)
+ * @see #getThreadMemberById(long)
*/
@Nullable
default ThreadMember getOwnerThreadMember()
@@ -477,7 +516,7 @@ default ThreadMember getOwnerThreadMember()
/**
* Whether this thread has been archived.
*
- * This method will consider locked channels to also be 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.
@@ -485,10 +524,10 @@ default ThreadMember getOwnerThreadMember()
*
* @return true if this thread has been archived, false otherwise.
*
- * @see #isLocked()
- * @see ThreadChannelManager#setArchived(boolean)
- * @see #getAutoArchiveDuration()
- * @see ChannelField#ARCHIVED
+ * @see #isLocked()
+ * @see ThreadChannelManager#setArchived(boolean)
+ * @see #getAutoArchiveDuration()
+ * @see ChannelField#ARCHIVED
*/
boolean isArchived();
@@ -504,20 +543,20 @@ default ThreadMember getOwnerThreadMember()
*
* @return the time of the last archive info update.
*
- * @see ChannelField#ARCHIVED_TIMESTAMP
+ * @see ChannelField#ARCHIVED_TIMESTAMP
*/
OffsetDateTime getTimeArchiveInfoLastModified();
/**
* The inactivity timeout of this thread.
*
- * If a message is not sent within this amount of time, the thread will be automatically archived.
+ * If a message is not sent within this amount of time, the thread will be automatically hidden.
*
- * A thread archived this way can be unarchived by any member.
+ * A thread archived this way can be unarchived by any member.
*
- * @return the time before which a thread will automatically be archived.
+ * @return The inactivity timeframe until a thread is automatically hidden.
*
- * @see ChannelField#AUTO_ARCHIVE_DURATION
+ * @see ChannelField#AUTO_ARCHIVE_DURATION
*/
@Nonnull
AutoArchiveDuration getAutoArchiveDuration();
@@ -532,19 +571,10 @@ default ThreadMember getOwnerThreadMember()
@Nonnull
OffsetDateTime getTimeCreated();
- /**
- * The slowmode time of this thread. This determines the time each non-moderator must wait before sending another message.
- *
- * @return The amount of time in seconds a ThreadMember must wait between sending messages.
- *
- * @see net.dv8tion.jda.api.managers.channel.concrete.ThreadChannelManager#setSlowmode(int)
- */
- int getSlowmode();
-
/**
* 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.
+ * Note that joining threads is not a requirement of getting events about the thread.
*
* The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
@@ -594,7 +623,6 @@ default ThreadMember getOwnerThreadMember()
//this is probably also affected by private threads that are not invitable
/**
* Adds a member to this thread.
- *
* The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
@@ -656,16 +684,14 @@ default ThreadMember getOwnerThreadMember()
*
* The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
@@ -695,7 +720,6 @@ default RestAction The following {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} are possible:
@@ -735,7 +757,6 @@ default RestAction This is the time before an idle thread will be automatically hidden.
*
- * Sending a message to the thread will reset the timer.
+ * Sending a message to the thread will reset the timer.
*
* @see ChannelField#AUTO_ARCHIVE_DURATION
*/
- enum AutoArchiveDuration {
- //TODO: I dislike this naming scheme. Need to come up with something better.
+ enum AutoArchiveDuration
+ {
TIME_1_HOUR(60),
TIME_24_HOURS(1440),
TIME_3_DAYS(4320),
@@ -946,11 +964,27 @@ enum AutoArchiveDuration {
this.minutes = minutes;
}
+ /**
+ * The number of minutes before an idle thread will be automatically hidden.
+ *
+ * @return The number of minutes
+ */
public int getMinutes()
{
return minutes;
}
+ /**
+ * Provides the corresponding enum constant for the provided number of minutes.
+ *
+ * @param minutes
+ * The number of minutes. (must be one of the valid values)
+ *
+ * @throws IllegalArgumentException
+ * If the provided minutes is not a valid value.
+ *
+ * @return The corresponding enum constant.
+ */
@Nonnull
public static AutoArchiveDuration fromKey(int minutes)
{
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/forums/BaseForumTag.java b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/BaseForumTag.java
new file mode 100644
index 0000000000..13c6d48fc6
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/BaseForumTag.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel.forums;
+
+import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
+import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
+import net.dv8tion.jda.api.entities.emoji.UnicodeEmoji;
+import net.dv8tion.jda.api.utils.data.DataObject;
+import net.dv8tion.jda.api.utils.data.SerializableData;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Information describing a forum tag.
+ * Possible ErrorResponses include:
@@ -95,6 +94,7 @@ public interface GuildChannel extends Channel, Comparable Requirements Requirements Requirements Requirements Identifier: {@code emoji}
+ */
+public class ForumTagUpdateEmojiEvent extends GenericForumTagUpdateEvent Requirements Identifier: {@code moderated}
+ */
+@SuppressWarnings("ConstantConditions")
+public class ForumTagUpdateModeratedEvent extends GenericForumTagUpdateEvent Requirements Identifier: {@code name}
+ */
+@SuppressWarnings("ConstantConditions")
+public class ForumTagUpdateNameEvent extends GenericForumTagUpdateEvent Requirements This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return The tags that were added to the post
+ */
+ @Nonnull
+ public List This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return The tags that were removed from the post
+ */
+ @Nonnull
+ public List This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return The updated list of applied tags
+ */
+ @Nonnull
+ public List This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ *
+ * @return The previous list of applied tags
+ */
+ @Nonnull
+ public List Can be used to retrieve the old default reaction and the new one.
+ *
+ * @see ChannelField#DEFAULT_REACTION_EMOJI
+ */
+public class ChannelUpdateDefaultReactionEvent extends GenericChannelUpdateEvent Can be used to retrieve the old default sort order and the new one.
+ *
+ * @see ChannelField#DEFAULT_SORT_ORDER
+ */
+@SuppressWarnings("ConstantConditions")
+public class ChannelUpdateDefaultSortOrderEvent extends GenericChannelUpdateEvent Can be used to retrieve the old default thread slowmode and the new one.
+ *
+ * @see ChannelField#DEFAULT_THREAD_SLOWMODE
+ */
+public class ChannelUpdateDefaultThreadSlowmodeEvent extends GenericChannelUpdateEvent Can be used to retrieve the old flags and the new ones.
+ *
+ * @see ChannelField#FLAGS
+ */
+public class ChannelUpdateFlagsEvent extends GenericChannelUpdateEvent A channel name must not be {@code null} nor empty or more than 100 characters long!
+ * A channel name must not be {@code null} nor empty or more than {@value Channel#MAX_NAME_LENGTH} characters long!
* Example: {@code mod-only} or {@code generic_name}
@@ -166,7 +199,7 @@ default Guild getGuild()
* The new name for the selected {@link GuildChannel GuildChannel}
*
* @throws IllegalArgumentException
- * If the provided name is {@code null} or not between 1-100 characters long
+ * If the provided name is {@code null} or not between 1-{@value Channel#MAX_NAME_LENGTH} characters long
*
* @return ChannelManager for chaining convenience
*/
diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/attribute/ISlowmodeChannelManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/attribute/ISlowmodeChannelManager.java
new file mode 100644
index 0000000000..137d1553e3
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/managers/channel/attribute/ISlowmodeChannelManager.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.managers.channel.attribute;
+
+import net.dv8tion.jda.api.Permission;
+import net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel;
+import net.dv8tion.jda.api.managers.channel.ChannelManager;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nonnull;
+
+/**
+ * Manager which supports setting slowmode of a channel.
+ *
+ * @param A channel slowmode must not be negative nor greater than {@link ISlowmodeChannel#MAX_SLOWMODE}!
+ *
+ * Note: Bots are unaffected by this.
+ * Special case Example
+ * Example
+ * This is a full replacement of the tags list, all missing tags will be removed.
+ * You can use {@link ForumTagData} to create new tags or update existing ones.
+ *
+ * Example
+ * Example
+ * Example
+ * A channel slowmode must not be negative nor greater than {@link TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}!
- *
- * Note: Bots are unaffected by this.
- * A channel slowmode must not be negative nor greater than {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}!
- *
- * Note: Bots are unaffected by this.
- * A channel topic must not be more than {@code 1024} characters long!
- *
* @param topic
* The new topic for the selected channel,
* {@code null} or empty String to reset
*
* @throws IllegalArgumentException
- * If the provided topic is greater than {@code 1024} in length
+ * If the provided topic is greater than {@value StandardGuildMessageChannel#MAX_TOPIC_LENGTH} in length.
+ * For {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels},
+ * this limit is {@value net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#MAX_FORUM_TOPIC_LENGTH} instead.
*
* @return ChannelManager for chaining convenience
*/
diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/AbstractThreadCreateAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/AbstractThreadCreateAction.java
new file mode 100644
index 0000000000..6c45d16fa1
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/AbstractThreadCreateAction.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.requests.restaction;
+
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.channel.Channel;
+import net.dv8tion.jda.api.entities.channel.ChannelType;
+import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
+import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
+import net.dv8tion.jda.api.requests.RestAction;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nonnull;
+import java.util.function.Consumer;
+
+/**
+ * Common features of all {@link RestAction RestActions} that create a new thread.
+ *
+ * @param Note: Bots are unaffected by this.
* You can use {@link ForumTagData} to create new tags.
+ *
+ * @param tags
+ * The new available tags in the desired order.
+ *
+ * @throws IllegalArgumentException
+ * If the provided list is null or contains null elements
+ *
+ * @return The current ChannelAction, for chaining convenience
+ *
+ * @see ForumChannel#getAvailableTags()
+ */
+ @Nonnull
+ @CheckReturnValue
+ ChannelAction On success, this provides a {@link ForumPost} object with the {@link ForumPost#getMessage() starter message}
+ * and the {@link ForumPost#getThreadChannel() thread channel} of the post.
+ *
+ * @see net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#createForumPost(String, MessageCreateData)
+ */
+public interface ForumPostAction extends AbstractThreadCreateAction
This includes hidden channels by default.
+ *
This includes all types of channels, except for threads.
+ *
This includes hidden channels by default,
+ * you can use {@link #getChannels(boolean) getChannels(false)} to exclude hidden channels.
*
*
- *
@@ -1313,23 +1317,20 @@ default List
- *
*
This includes all types of channels, except for threads.
*
*
- *
*
- *
* @param includeHidden
* Whether to include channels with denied {@link Permission#VIEW_CHANNEL View Channel Permission}
*
@@ -3889,12 +3890,12 @@ default AuditableRestAction
- *
*
This action allows to set fields for the new TextChannel before creating it
@@ -3921,14 +3922,14 @@ default ChannelAction
This action allows to set fields for the new NewsChannel before creating it
@@ -3985,14 +3986,14 @@ default ChannelAction
This action allows to set fields for the new VoiceChannel before creating it
@@ -4049,14 +4050,14 @@ default ChannelAction
This action allows to set fields for the new StageChannel before creating it
@@ -4113,14 +4114,14 @@ default ChannelAction
+ *
+ *
+ * @param name
+ * The name of the ForumChannel to create (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ *
+ * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
+ * If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
+ * @throws IllegalArgumentException
+ * If the provided name is {@code null}, blank, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ *
+ * @return A specific {@link ChannelAction ChannelAction}
+ *
The channel could not be created due to a permission discrepancy
The maximum number of channels were exceeded
This action allows to set fields for the new ForumChannel before creating it
+ */
+ @Nonnull
+ @CheckReturnValue
+ default ChannelAction
+ *
+ *
+ * @param name
+ * The name of the ForumChannel to create (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ * @param parent
+ * The optional parent category for this channel, or null
+ *
+ * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
+ * If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
+ * @throws IllegalArgumentException
+ * If the provided name is {@code null}, blank, or longer than {@value Channel#MAX_NAME_LENGTH} characters;
+ * or the provided parent is not in the same guild.
+ *
+ * @return A specific {@link ChannelAction ChannelAction}
+ *
The channel could not be created due to a permission discrepancy
The maximum number of channels were exceeded
This action allows to set fields for the new ForumChannel before creating it
+ */
+ @Nonnull
+ @CheckReturnValue
+ ChannelAction
This action allows to set fields for the new Category before creating it
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/Channel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/Channel.java
index c281abae16..b3101cc2fa 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/Channel.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/Channel.java
@@ -23,6 +23,7 @@
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
+import java.util.EnumSet;
import java.util.FormattableFlags;
import java.util.Formatter;
@@ -31,6 +32,23 @@
*/
public interface Channel extends IMentionable
{
+ /**
+ * The maximum length a channel name can be. ({@value #MAX_NAME_LENGTH})
+ */
+ int MAX_NAME_LENGTH = 100;
+
+ /**
+ * The flags configured for this channel.
+ *
This feature is currently primarily used for {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels}.
+ *
+ * @return {@link EnumSet} of the configured {@link ChannelFlag ChannelFlags}, changes to this enum set are not reflected in the API.
+ */
+ @Nonnull
+ default EnumSet
This defines the minimum time between message sends.
*
- * Limited to {@link TextChannel Text Channels}.
+ *
* The bitrates of boost tiers may be found in {@link Guild.BoostTier the boost tiers}.
*
- * Limited to {@link AudioChannel Audio Channels}.
+ *
*
*
* @param id
@@ -175,6 +176,8 @@ default GuildChannel getGuildChannelById(long id)
channel = getCategoryById(id);
if (channel == null)
channel = getThreadChannelById(id);
+ if (channel == null)
+ channel = getForumChannelById(id);
return channel;
}
@@ -200,6 +203,7 @@ default GuildChannel getGuildChannelById(long id)
*
If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
+ * To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
+ *
+ * @return {@link SnowflakeCacheView SnowflakeCacheView}
+ */
+ @Nonnull
+ SnowflakeCacheView
If there are no channels with the provided name, then this returns an empty list.
+ *
+ *
If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
+ * To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
+ *
+ * @param name
+ * The name used to filter the returned {@link ForumChannel ForumChannels}.
+ * @param ignoreCase
+ * Determines if the comparison ignores case when comparing. True - case insensitive.
+ *
+ * @return Possibly-empty immutable list of all ForumChannel names that match the provided name.
+ */
+ @Nonnull
+ default List
If there is no channel with an id that matches the provided one, then this returns {@code null}.
+ *
+ *
If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
+ * To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
+ *
+ * @param id
+ * The id of the {@link ForumChannel}.
+ *
+ * @throws java.lang.NumberFormatException
+ * If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
+ *
+ * @return Possibly-null {@link ForumChannel} with matching id.
+ */
+ @Nullable
+ default ForumChannel getForumChannelById(@Nonnull String id)
+ {
+ return getForumChannelCache().getElementById(id);
+ }
+
+ /**
+ * Gets a {@link ForumChannel} that has the same id as the one provided.
+ *
If there is no channel with an id that matches the provided one, then this returns {@code null}.
+ *
+ *
If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
+ * To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
+ *
+ * @param id
+ * The id of the {@link ForumChannel}.
+ *
+ * @return Possibly-null {@link ForumChannel} with matching id.
+ */
+ @Nullable
+ default ForumChannel getForumChannelById(long id)
+ {
+ return getForumChannelCache().getElementById(id);
+ }
+
+ /**
+ * Gets all {@link ForumChannel} in the cache.
+ *
+ *
If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
+ * To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
+ *
+ * @return An immutable List of {@link ForumChannel}.
+ */
+ @Nonnull
+ default List
If slowmode is set, this returns an {@code int} between 1 and {@value #MAX_SLOWMODE}.
+ *
Otherwise, if no slowmode is set, this returns {@code 0}.
+ *
+ *
Having {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
+ * {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
+ * grants immunity to slowmode.
+ *
+ *
+ * {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels} use this to limit how many posts a user can create.
+ * The client refers to this as the post slowmode.
+ *
+ * @return The slowmode for this channel, between 1 and {@value #MAX_SLOWMODE}, or {@code 0} if no slowmode is set.
+ */
+ int getSlowmode();
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/attribute/IThreadContainer.java b/src/main/java/net/dv8tion/jda/api/entities/channel/attribute/IThreadContainer.java
index 07eaa4013c..98003a8a94 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/attribute/IThreadContainer.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/attribute/IThreadContainer.java
@@ -16,6 +16,8 @@
package net.dv8tion.jda.api.entities.channel.attribute;
+import net.dv8tion.jda.api.entities.MessageType;
+import net.dv8tion.jda.api.entities.channel.Channel;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
@@ -23,6 +25,7 @@
import net.dv8tion.jda.api.requests.restaction.ThreadChannelAction;
import net.dv8tion.jda.api.requests.restaction.pagination.ThreadChannelPaginationAction;
import net.dv8tion.jda.api.utils.MiscUtil;
+import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
@@ -30,29 +33,40 @@
import java.util.List;
import java.util.stream.Collectors;
+/**
+ * Abstraction of all channel types, which can contain or manage {@link ThreadChannel ThreadChannels}.
+ *
+ * @see ThreadChannel#getParentChannel()
+ * @see net.dv8tion.jda.api.entities.channel.unions.IThreadContainerUnion IThreadContainerUnion
+ */
public interface IThreadContainer extends GuildChannel, IPermissionContainer
{
+ /**
+ * The default {@link ISlowmodeChannel#getSlowmode() slowmode} for thread channels that is copied on thread creation.
+ *
Users have to wait this amount of seconds before sending another message to the same thread.
+ *
+ * @return The default slowmode seconds for new threads, or {@code 0} if unset
+ */
+ int getDefaultThreadSlowmode();
+
/**
* Finds all {@link ThreadChannel ThreadChannels} whose parent is this channel.
*
- * @return a list of all ThreadChannel children.
+ * @return Immutable list of all ThreadChannel children.
*/
default List
*
*
- * @param name
- * The name of the new ThreadChannel
+ * @param name
+ * The name of the new ThreadChannel (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ *
+ * @throws IllegalArgumentException
+ * If the provided name is null, blank, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ * @throws UnsupportedOperationException
+ * If this is a forum channel.
+ * You must use {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#createForumPost(String, MessageCreateData) createForumPost(...)} instead.
+ * @throws InsufficientPermissionException
+ *
The maximum number of active threads has been reached, and no more may be created.
+ *
*
* @return A specific {@link ThreadChannelAction} that may be used to configure the new ThreadChannel before its creation.
*/
@Nonnull
@CheckReturnValue
- default ThreadChannelAction createThreadChannel(String name)
+ default ThreadChannelAction createThreadChannel(@Nonnull String name)
{
return createThreadChannel(name, false);
}
/**
* Creates a new {@link ThreadChannel} with the parent channel being this {@link IThreadContainer}.
- * This requires the bot to have the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL} and {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS} permissions.
*
- * The resulting {@link ThreadChannel ThreadChannel} may be one of:
+ *
*
*
* @param name
- * The name of the new ThreadChannel
+ * The name of the new ThreadChannel (up to {@value Channel#MAX_NAME_LENGTH} characters)
* @param isPrivate
* The public/private status of the new ThreadChannel. If true, the new ThreadChannel will be private.
*
+ * @throws IllegalArgumentException
+ * If the provided name is null, blank, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ * @throws UnsupportedOperationException
+ * If this is a forum channel.
+ * You must use {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#createForumPost(String, MessageCreateData) createForumPost(...)} instead.
* @throws InsufficientPermissionException
- * if the ThreadChannel is set to private, and the logged in account does not have {@link net.dv8tion.jda.api.Permission#CREATE_PRIVATE_THREADS}.
+ *
Due to missing private thread permissions.
+ *
*
* @return A specific {@link ThreadChannelAction} that may be used to configure the new ThreadChannel before its creation.
*/
@Nonnull
@CheckReturnValue
- ThreadChannelAction createThreadChannel(String name, boolean isPrivate);
-
+ ThreadChannelAction createThreadChannel(@Nonnull String name, boolean isPrivate);
/**
* Creates a new, public {@link ThreadChannel} with the parent channel being this {@link IThreadContainer}.
- * This ThreadChannel will be spawned from the given messageID, and will consequently share its ID with the message.
- * This requires the bot to have {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL} and {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS} permissions.
+ *
The starting message will copy the message for the provided id, and will be of type {@link MessageType#THREAD_STARTER_MESSAGE MessageType.THREAD_STARTER_MESSAGE}.
*
- * The resulting {@link ThreadChannel ThreadChannel} may be one of:
+ *
*
*
- * @param name
- * The name of the new ThreadChannel
- * @param messageId
- * The ID of the message from which this ThreadChannel will be spawned.
+ * @param name
+ * The name of the new ThreadChannel (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ * @param messageId
+ * The ID of the message from which this ThreadChannel will be spawned.
+ *
+ * @throws IllegalArgumentException
+ * If the provided name is null, blank, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ * @throws UnsupportedOperationException
+ * If this is a forum channel.
+ * You must use {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#createForumPost(String, MessageCreateData) createForumPost(...)} instead.
+ * @throws InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS Permission.CREATE_PUBLIC_THREADS} in this channel
*
* @return A specific {@link ThreadChannelAction} that may be used to configure the new ThreadChannel before its creation.
*/
@Nonnull
@CheckReturnValue
- ThreadChannelAction createThreadChannel(String name, long messageId);
+ ThreadChannelAction createThreadChannel(@Nonnull String name, long messageId);
/**
* Creates a new, public {@link ThreadChannel} with the parent channel being this {@link IThreadContainer}.
- * This ThreadChannel will be spawned from the given messageID, and will consequently share its ID with the message.
- * This requires the bot to have {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL} and {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS} permissions.
+ *
The maximum number of active threads has been reached, and no more may be created.
The starting message will copy the message for the provided id, and will be of type {@link MessageType#THREAD_STARTER_MESSAGE MessageType.THREAD_STARTER_MESSAGE}.
*
- * The resulting {@link ThreadChannel ThreadChannel} may be one of:
+ *
*
*
- * @param name
- * The name of the new ThreadChannel
- * @param messageId
- * The ID of the message from which this ThreadChannel will be spawned.
+ * @param name
+ * The name of the new ThreadChannel (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ * @param messageId
+ * The ID of the message from which this ThreadChannel will be spawned.
+ *
+ * @throws IllegalArgumentException
+ * If the provided name is null, blank, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters.
+ * Or the message id is not a valid snowflake.
+ * @throws UnsupportedOperationException
+ * If this is a forum channel.
+ * You must use {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel#createForumPost(String, MessageCreateData) createForumPost(...)} instead.
+ * @throws InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS Permission.CREATE_PUBLIC_THREADS} in this channel
*
* @return A specific {@link ThreadChannelAction} that may be used to configure the new ThreadChannel before its creation.
*/
@Nonnull
@CheckReturnValue
- default ThreadChannelAction createThreadChannel(String name, String messageId)
+ default ThreadChannelAction createThreadChannel(@Nonnull String name, @Nonnull String messageId)
{
return createThreadChannel(name, MiscUtil.parseSnowflake(messageId));
}
- //TODO-v5: Docs
+ /**
+ * Retrieves the archived public {@link ThreadChannel ThreadChannels} for this channel.
+ *
The maximum number of active threads has been reached, and no more may be created.
This will iterate over all previously opened public threads, that have been archived.
+ *
+ *
This will iterate over all previously opened private threads, that have been archived.
+ * This is a moderator restricted method, since private threads are only visible to members with {@link net.dv8tion.jda.api.Permission#MANAGE_THREADS Permission.MANAGE_THREADS}.
+ *
+ *
Unlike {@link #retrieveArchivedPrivateThreadChannels()}, this only checks for threads which the bot has joined, and thus does not require permissions to manage threads.
+ *
+ *
This may contain {@link VoiceChannel VoiceChannels},
- * and {@link TextChannel TextChannels}!
+ * All {@link GuildChannel Channels} listed for this Category.
+ *
Includes all types of channels, except for threads.
*
* @return Immutable list of all child channels
*/
@@ -72,6 +71,7 @@ default List
This action allows to set fields for the new TextChannel before creating it
@@ -170,6 +193,43 @@ default List
+ *
+ *
+ * @param name
+ * The name of the NewsChannel to create (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ *
+ * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
+ * If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
+ * @throws IllegalArgumentException
+ * If the provided name is {@code null}, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ *
+ * @return A specific {@link ChannelAction ChannelAction}
+ *
The channel could not be created due to a permission discrepancy
The {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission was removed
The maximum number of channels were exceeded
This action allows to set fields for the new NewsChannel before creating it
+ */
+ @Nonnull
+ @CheckReturnValue
+ ChannelAction
This action allows to set fields for the new VoiceChannel before creating it
@@ -230,12 +290,12 @@ default List
This action allows to set fields for the new StageChannel before creating it
@@ -244,6 +304,43 @@ default List
+ *
+ *
+ * @param name
+ * The name of the ForumChannel to create (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ *
+ * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
+ * If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL} permission
+ * @throws IllegalArgumentException
+ * If the provided name is {@code null}, empty, or longer than {@value Channel#MAX_NAME_LENGTH} characters
+ *
+ * @return A specific {@link ChannelAction ChannelAction}
+ *
The channel could not be created due to a permission discrepancy
The {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL VIEW_CHANNEL} permission was removed
The maximum number of channels were exceeded
This action allows to set fields for the new ForumChannel before creating it
+ */
+ @Nonnull
+ @CheckReturnValue
+ ChannelAction
This uses an extension of {@link ChannelOrderAction ChannelOrderAction}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ForumChannel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ForumChannel.java
new file mode 100644
index 0000000000..ff3e7f3656
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ForumChannel.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel.concrete;
+
+import net.dv8tion.jda.annotations.Incubating;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.channel.Channel;
+import net.dv8tion.jda.api.entities.channel.ChannelFlag;
+import net.dv8tion.jda.api.entities.channel.ChannelType;
+import net.dv8tion.jda.api.entities.channel.attribute.IAgeRestrictedChannel;
+import net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel;
+import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
+import net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
+import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel;
+import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
+import net.dv8tion.jda.api.managers.channel.concrete.ForumChannelManager;
+import net.dv8tion.jda.api.requests.restaction.ChannelAction;
+import net.dv8tion.jda.api.requests.restaction.ForumPostAction;
+import net.dv8tion.jda.api.utils.cache.SortedSnowflakeCacheView;
+import net.dv8tion.jda.api.utils.messages.MessageCreateData;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A Forum Channel which contains {@link #createForumPost(String, MessageCreateData) Forum Posts}.
+ *
Forum posts are simply {@link ThreadChannel ThreadChannels} of type {@link ChannelType#GUILD_PUBLIC_THREAD}.
+ *
+ *
Tags are sorted by their {@link ForumTag#getPosition() position} ascending.
+ *
+ *
Tags are sorted by their {@link ForumTag#getPosition() position} ascending.
+ *
+ *
Tags are sorted by their {@link ForumTag#getPosition() position} ascending.
+ *
+ *
If no topic has been set, this returns null.
+ *
+ * @return Possibly-null String containing the topic of this channel.
+ */
+ @Nullable
+ String getTopic();
+
+ /**
+ * Whether all new forum posts must have a tag.
+ *
+ * @return True, if all new posts must have a tag.
+ */
+ default boolean isTagRequired()
+ {
+ return getFlags().contains(ChannelFlag.REQUIRE_TAG);
+ }
+
+ /**
+ * The emoji which will show up on new forum posts as default reaction.
+ *
+ * @return The default reaction for new forum posts.
+ */
+ @Nullable
+ EmojiUnion getDefaultReaction();
+
+ /**
+ * The default order used to show threads.
+ *
+ * @return The default order used to show threads.
+ */
+ @Nonnull
+ SortOrder getDefaultSortOrder();
+
+ /**
+ * Creates a new forum post (thread) in this forum.
+ *
+ *
+ *
+ *
+ * @param name
+ * The name of the post (up to {@value Channel#MAX_NAME_LENGTH} characters)
+ * @param message
+ * The starting message of the post (see {@link net.dv8tion.jda.api.utils.messages.MessageCreateBuilder MessageCreateBuilder})
+ *
+ * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
+ * If the bot does not have {@link net.dv8tion.jda.api.Permission#MESSAGE_SEND Permission.MESSAGE_SEND} in the channel
+ * @throws IllegalArgumentException
+ *
If the forum channel was deleted
If the total sum of uploaded bytes exceeds the guild's {@link Guild#getMaxFileSize() upload limit}
+ *
+ *
+ * @return {@link ForumPostAction}
+ */
+ @Nonnull
+ @Incubating
+ @CheckReturnValue
+ ForumPostAction createForumPost(@Nonnull String name, @Nonnull MessageCreateData message);
+
+ /**
+ * The order used to sort forum posts.
+ */
+ enum SortOrder
+ {
+ /**
+ * Sort by recent activity, including unarchive, message, reaction, and thread creation.
+ */
+ RECENT_ACTIVITY(0),
+ /**
+ * Sort by the time the post was originally created.
+ */
+ CREATION_TIME(1),
+ /**
+ * Placeholder for possible future order modes.
+ */
+ UNKNOWN(-1),
+ ;
+
+ private final int order;
+
+ SortOrder(int order)
+ {
+ this.order = order;
+ }
+
+ /**
+ * The underlying value as used by Discord.
+ *
+ * @return The raw order key
+ */
+ public int getKey()
+ {
+ return order;
+ }
+
+ /**
+ * The {@link SortOrder} for the provided key.
+ *
+ * @param key
+ * The key to get the {@link SortOrder} for
+ *
+ * @return The {@link SortOrder} for the provided key, or {@link #UNKNOWN} if the key is not known
+ */
+ @Nonnull
+ public static SortOrder fromKey(int key)
+ {
+ for (SortOrder order : values())
+ {
+ if (order.order == key)
+ return order;
+ }
+
+ return UNKNOWN;
+ }
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/TextChannel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/TextChannel.java
index 6cd02880f0..a821fa5515 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/TextChannel.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/TextChannel.java
@@ -17,6 +17,7 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildMessageChannel;
import net.dv8tion.jda.api.managers.channel.concrete.TextChannelManager;
import net.dv8tion.jda.api.requests.restaction.ChannelAction;
@@ -44,27 +45,8 @@
* @see JDA#getTextChannelsByName(String, boolean)
* @see JDA#getTextChannelById(long)
*/
-public interface TextChannel extends StandardGuildMessageChannel
+public interface TextChannel extends StandardGuildMessageChannel, ISlowmodeChannel
{
- /**
- * The maximum duration of slowmode in seconds
- */
- int MAX_SLOWMODE = 21600;
-
- /**
- * The slowmode set for this TextChannel.
- *
If slowmode is set this returns an {@code int} between 1 and {@link TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}.
- *
If not set this returns {@code 0}.
- *
- *
Having {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
- * {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
- * grants immunity to slowmode.
- *
- * @return The slowmode for this TextChannel, between 1 and {@link TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}, or {@code 0} if no slowmode is set.
- */
- int getSlowmode();
-
@Nonnull
@Override
ChannelAction
+ *
+ *
+ *
- * Threads started from seed messages in the {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer parent channel} will not count that seed message.
- *
- * This will be capped at 50, regardless of actual count.
+ *
Threads started from seed messages in the {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer parent channel} will not count that seed message.
+ *
This will be capped at 50 for threads created before July 1, 2022.
*
- * @return The number of messages sent in this channel, capping at 50.
+ * @return The number of messages sent in this thread
*/
int getMessageCount();
+ /**
+ * The total number of messages sent in this thread, including all deleted messages.
+ *
This might be inaccurate for threads created before July 1, 2022.
+ *
+ * @return The total number of messages ever sent in this thread
+ */
+ int getTotalMessageCount();
+
/**
* 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.
+ *
This is capped at 50, meaning any additional members will not affect this count.
*
* @return The number of members that have joined this thread, capping at 50.
*/
@@ -91,12 +112,12 @@ default boolean isJoined()
/**
* Whether this thread is locked or not.
*
- * Locked threads cannot have new messages posted to them, or members join or leave them.
+ *
- * This is a convenience method that will perform the cast if possible, throwing otherwise.
- *
- * @return The parent channel of this thread, as a {@link GuildMessageChannel}.
+ * Gets the {@link GuildMessageChannelUnion parent channel} of this thread, if it is a {@link TextChannel}, {@link NewsChannel}, or {@link VoiceChannel}.
+ *
This is a convenience method that will perform the cast if possible, throwing otherwise.
*
* @throws UnsupportedOperationException
* If the parent channel is not a {@link GuildMessageChannel}.
+ *
+ * @return The parent channel of this thread, as a {@link GuildMessageChannelUnion}.
*/
@Nonnull
default GuildMessageChannelUnion getParentMessageChannel()
{
- if (getParentChannel() instanceof GuildMessageChannel) {
+ if (getParentChannel() instanceof GuildMessageChannel)
return (GuildMessageChannelUnion) getParentChannel();
- }
- throw new UnsupportedOperationException("Parent of this thread is not a MessageChannel. Parent is type: " + getParentChannel().getType().getId());
+ throw new UnsupportedOperationException("Parent of this thread is not a MessageChannel. Parent: " + getParentChannel());
}
+ /**
+ * The {@link net.dv8tion.jda.api.entities.channel.forums.ForumTag forum tags} applied to this thread.
+ *
This will be an empty list if the thread was not created in a {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannel}.
+ *
+ * @return Immutable {@link List} of {@link net.dv8tion.jda.api.entities.channel.forums.ForumTag ForumTags} applied to this post
+ */
+ @Nonnull
+ List
If the current account is not a member of this thread, this will return null.
+ *
- *
The thread owner is not included in this list, unless the current account is the owner.
+ *
+ *
- * This will be null if the member is not cached, and so it is recommended to {@link Guild#retrieveMemberById(long) retrieve this member from the guild} using {@link #getOwnerIdLong() the owner'd ID}.
+ *
This will be null if the member is not cached,
+ * and so it is recommended to {@link Guild#retrieveMemberById(long) retrieve this member from the guild}
+ * using {@link #getOwnerIdLong() the owner'd ID}.
*
* @return The {@link Member} of the member who created this thread.
*
- * @see #getThreadMemberById(long)
- * @see Guild#retrieveMemberById(long)
+ * @see #getThreadMemberById(long)
+ * @see Guild#retrieveMemberById(long)
*/
@Nullable
default Member getOwner()
@@ -459,14 +497,15 @@ default Member getOwner()
/**
* Gets the owner of this thread as a {@link ThreadMember}.
- *
- * This will be null if the member is not cached, and so it is recommended to retrieve the owner instead.
+ *
This will be null if the member is not cached, and so it is recommended to retrieve the owner instead.
*
- *
This method relies on the {@link #getThreadMembers()} cache, and so it is recommended to {@link #retrieveThreadMemberById(long) retrieve the ThreadMember} by {@link #getOwnerIdLong() their ID} instead.
+ *
This will have no effect if the current account is already a member of this thread.
*
@@ -569,7 +599,6 @@ default ThreadMember getOwnerThreadMember()
/**
* 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.
*
*
This will have no effect if the member is already a member of this thread.
*
*
The provided User ID is not a valid snowflake.
This will have no effect if the member is already a member of this thread.
*
*
The request was attempted after the channel was deleted.
This will have no effect if the member is already a member of this thread.
*
*
The request was attempted after the channel was deleted.
This is an abstraction used to simplify managing tags.
+ *
+ * @see ForumTag
+ * @see ForumTagData
+ * @see ForumTagSnowflake
+ */
+public interface BaseForumTag extends SerializableData
+{
+ /**
+ * The name of the tag.
+ *
+ * @return The name
+ */
+ @Nonnull
+ String getName();
+
+ /**
+ * Whether this tag can only be applied by moderators with the {@link net.dv8tion.jda.api.Permission#MANAGE_THREADS MANAGE_THREADS} permission (aka Manage Posts).
+ *
+ * @return True, if this tag can only be applied by moderators with the required permission
+ */
+ boolean isModerated();
+
+ /**
+ * The emoji used as the tag icon.
+ *
For custom emoji, this will have an empty name and {@link CustomEmoji#isAnimated()} is always {@code false}, due to discord chicanery.
+ *
+ * @return {@link EmojiUnion} representing the tag emoji, or null if no emoji is applied.
+ */
+ @Nullable
+ EmojiUnion getEmoji();
+
+ @Nonnull
+ @Override
+ default DataObject toData()
+ {
+ DataObject json = DataObject.empty()
+ .put("name", getName())
+ .put("moderated", isModerated());
+ EmojiUnion emoji = getEmoji();
+ if (emoji instanceof UnicodeEmoji)
+ json.put("emoji_name", emoji.getName());
+ else if (emoji instanceof CustomEmoji)
+ json.put("emoji_id", ((CustomEmoji) emoji).getId());
+ return json;
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumPost.java b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumPost.java
new file mode 100644
index 0000000000..b2b6b58f38
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumPost.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel.forums;
+
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
+import net.dv8tion.jda.api.utils.messages.MessageCreateData;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Result of creating a post in a {@link ForumChannel}.
+ *
+ * @see ForumChannel#createForumPost(String, MessageCreateData)
+ * @see #getThreadChannel()
+ * @see #getMessage()
+ */
+public class ForumPost
+{
+ private final Message message;
+ private final ThreadChannel thread;
+
+ public ForumPost(@Nonnull Message message, @Nonnull ThreadChannel thread)
+ {
+ this.message = message;
+ this.thread = thread;
+ }
+
+ /**
+ * The starter message of the post.
+ *
This is created from the {@link MessageCreateData} passed to {@link ForumChannel#createForumPost(String, MessageCreateData)}.
+ *
+ * @return {@link Message}
+ */
+ @Nonnull
+ public Message getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * The {@link ThreadChannel} of the post.
+ *
This will use the name provided to {@link ForumChannel#createForumPost(String, MessageCreateData)}.
+ *
+ * @return The forum post thread channel
+ */
+ @Nonnull
+ public ThreadChannel getThreadChannel()
+ {
+ return thread;
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTag.java b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTag.java
new file mode 100644
index 0000000000..989dfde283
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTag.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel.forums;
+
+import net.dv8tion.jda.api.entities.ISnowflake;
+import net.dv8tion.jda.api.utils.data.DataObject;
+import net.dv8tion.jda.internal.utils.Checks;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Represents a Discord Forum Tag.
+ *
These tags can be applied to forum posts to help categorize them.
+ */
+public interface ForumTag extends ISnowflake, Comparable
This also binds to the id of the provided tag, if available.
+ *
+ * @param tag
+ * The base tag to use
+ *
+ * @throws IllegalArgumentException
+ * If null is provided or the tag has an invalid name
+ *
+ * @return The new {@link ForumTagData} instance
+ */
+ @Nonnull
+ public static ForumTagData from(@Nonnull BaseForumTag tag)
+ {
+ Checks.notNull(tag, "Tag");
+ ForumTagData data = new ForumTagData(tag.getName())
+ .setEmoji(tag.getEmoji())
+ .setModerated(tag.isModerated());
+ if (tag instanceof ForumTagSnowflake)
+ data.id = ((ForumTagSnowflake) tag).getIdLong();
+ return data;
+ }
+
+ /**
+ * Set the new tag name to use.
+ *
+ * @param name
+ * The new tag name (1-{@value ForumTag#MAX_NAME_LENGTH} characters)
+ *
+ * @throws IllegalArgumentException
+ * If the provided name is null or not between 1 and {@value ForumTag#MAX_NAME_LENGTH} characters long
+ *
+ * @return The updated ForumTagData instance
+ */
+ @Nonnull
+ public ForumTagData setName(@Nonnull String name)
+ {
+ Checks.notEmpty(name, "Name");
+ Checks.notLonger(name, ForumTag.MAX_NAME_LENGTH, "Name");
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Set whether the tag can only be applied by forum moderators.
+ *
+ * @param moderated
+ * True, if the tag is restricted to moderators
+ *
+ * @return The updated ForumTagData instance
+ *
+ * @see #isModerated()
+ */
+ @Nonnull
+ public ForumTagData setModerated(boolean moderated)
+ {
+ this.moderated = moderated;
+ return this;
+ }
+
+ /**
+ * Set the emoji to use for this tag.
+ *
This emoji is displayed as an icon attached to the tag.
+ *
+ * @param emoji
+ * The emoji icon of the tag
+ *
+ * @return The updated ForumTagData instance
+ */
+ @Nonnull
+ public ForumTagData setEmoji(@Nullable Emoji emoji)
+ {
+ this.emoji = emoji;
+ return this;
+ }
+
+ @Nonnull
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean isModerated()
+ {
+ return moderated;
+ }
+
+ @Nullable
+ @Override
+ public EmojiUnion getEmoji()
+ {
+ return (EmojiUnion) emoji;
+ }
+
+ @Nonnull
+ @Override
+ public DataObject toData()
+ {
+ DataObject json = BaseForumTag.super.toData();
+ if (id != 0)
+ json.put("id", Long.toUnsignedString(id));
+ return json;
+ }
+
+ @Override
+ public String toString()
+ {
+ return toData().toString();
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTagSnowflake.java b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTagSnowflake.java
new file mode 100644
index 0000000000..76074da16d
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/forums/ForumTagSnowflake.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.entities.channel.forums;
+
+import net.dv8tion.jda.api.entities.ISnowflake;
+import net.dv8tion.jda.api.requests.restaction.ForumPostAction;
+import net.dv8tion.jda.api.utils.MiscUtil;
+import net.dv8tion.jda.internal.entities.ForumTagSnowflakeImpl;
+
+import javax.annotation.Nonnull;
+import java.util.Collection;
+
+/**
+ * Minimal representation for a forum tag.
+ *
This is primarily useful for creating posts with {@link ForumPostAction#setTags(Collection)}.
+ */
+public interface ForumTagSnowflake extends ISnowflake
+{
+ /**
+ * Wraps the provided id into a ForumTagSnowflake instance.
+ *
+ * @param id
+ * The id of an existing forum tag
+ *
+ * @return ForumTagSnowflake instance for the provided id
+ */
+ @Nonnull
+ static ForumTagSnowflake fromId(long id)
+ {
+ return new ForumTagSnowflakeImpl(id);
+ }
+
+ /**
+ * Wraps the provided id into a ForumTagSnowflake instance.
+ *
+ * @param id
+ * The id of an existing forum tag
+ *
+ * @throws IllegalArgumentException
+ * If the provided id is not a valid snowflake
+ *
+ * @return ForumTagSnowflake instance for the provided id
+ */
+ @Nonnull
+ static ForumTagSnowflake fromId(@Nonnull String id)
+ {
+ return new ForumTagSnowflakeImpl(MiscUtil.parseSnowflake(id));
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/GuildChannel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/GuildChannel.java
index cb36b6cddd..03683a09dd 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/GuildChannel.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/GuildChannel.java
@@ -67,7 +67,6 @@ public interface GuildChannel extends Channel, Comparable
Forum channels have a higher limit, defined by {@link ForumChannel#MAX_FORUM_TOPIC_LENGTH}
+ */
+ int MAX_TOPIC_LENGTH = 1024;
+
@Nonnull
@Override
StandardGuildMessageChannelManager, ?> getManager();
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/ChannelUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/ChannelUnion.java
index 2acf963fe3..980b1c4e57 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/ChannelUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/ChannelUnion.java
@@ -37,6 +37,7 @@
*
+ *
+ * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
+ * whether you can call this method in addition to normal instanceof checks:
+ * //These are the same!
+ * ForumChannel channel = union.asForumChannel();
+ * ForumChannel channel2 = (ForumChannel) union;
+ *
channel instanceof ForumChannel
+ *
+ * @throws IllegalStateException
+ * If the channel represented by this union is not actually a {@link ForumChannel}.
+ *
+ * @return The channel as a {@link ForumChannel}
+ */
+ @Nonnull
+ ForumChannel asForumChannel();
+
/**
* Casts this union to a {@link Category}.
* This method exists for developer discoverability.
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildChannelUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildChannelUnion.java
index 170233e0c5..afa6b4c7d3 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildChannelUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildChannelUnion.java
@@ -35,6 +35,7 @@
*
+ *
+ * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
+ * whether you can call this method in addition to normal instanceof checks:
+ * //These are the same!
+ * ForumChannel channel = union.asForumChannel();
+ * ForumChannel channel2 = (ForumChannel) union;
+ *
channel instanceof ForumChannel
+ *
+ * @throws IllegalStateException
+ * If the channel represented by this union is not actually a {@link ForumChannel}.
+ *
+ * @return The channel as a {@link ForumChannel}
+ */
+ @Nonnull
+ ForumChannel asForumChannel();
+
/**
* Casts this union to a {@link GuildMessageChannel}.
* This method exists for developer discoverability.
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildMessageChannelUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildMessageChannelUnion.java
index c13488e26e..3dbb14503c 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildMessageChannelUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildMessageChannelUnion.java
@@ -37,6 +37,7 @@
*
*
*/
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IPermissionContainerUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IPermissionContainerUnion.java
index 28d8755f8d..85bb3c9e0e 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IPermissionContainerUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IPermissionContainerUnion.java
@@ -38,6 +38,7 @@
*
+ *
+ * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
+ * whether you can call this method in addition to normal instanceof checks:
+ * //These are the same!
+ * ForumChannel channel = union.asForumChannel();
+ * ForumChannel channel2 = (ForumChannel) union;
+ *
channel instanceof ForumChannel
+ *
+ * @throws IllegalStateException
+ * If the channel represented by this union is not actually a {@link ForumChannel}.
+ *
+ * @return The channel as a {@link ForumChannel}
+ */
+ @Nonnull
+ ForumChannel asForumChannel();
+
/**
* Casts this union to a {@link GuildMessageChannel}.
* This method exists for developer discoverability.
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IThreadContainerUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IThreadContainerUnion.java
index 18546a9240..688403c9ee 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IThreadContainerUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IThreadContainerUnion.java
@@ -18,6 +18,7 @@
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
import net.dv8tion.jda.api.entities.channel.concrete.NewsChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
@@ -35,6 +36,7 @@
*
*
*/
public interface IThreadContainerUnion extends IThreadContainer
@@ -83,7 +85,27 @@ public interface IThreadContainerUnion extends IThreadContainer
@Nonnull
NewsChannel asNewsChannel();
- //TODO: Add asForumChannel
+ /**
+ * Casts this union to a {@link ForumChannel}.
+ * This method exists for developer discoverability.
+ *
+ * Note: This is effectively equivalent to using the cast operator:
+ *
+ *
+ * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
+ * whether you can call this method in addition to normal instanceof checks:
+ * //These are the same!
+ * ForumChannel channel = union.asForumChannel();
+ * ForumChannel channel2 = (ForumChannel) union;
+ *
channel instanceof ForumChannel
+ *
+ * @throws IllegalStateException
+ * If the channel represented by this union is not actually a {@link ForumChannel}.
+ *
+ * @return The channel as a {@link ForumChannel}
+ */
+ @Nonnull
+ ForumChannel asForumChannel();
/**
* Casts this union to a {@link GuildMessageChannel}.
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IWebhookContainerUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IWebhookContainerUnion.java
index 1b142e17d7..7715e494c1 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IWebhookContainerUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/IWebhookContainerUnion.java
@@ -19,6 +19,7 @@
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
import net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
import net.dv8tion.jda.api.entities.channel.concrete.NewsChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
@@ -37,6 +38,7 @@
*
*
*/
public interface IWebhookContainerUnion extends IWebhookContainer
@@ -85,7 +87,27 @@ public interface IWebhookContainerUnion extends IWebhookContainer
@Nonnull
NewsChannel asNewsChannel();
- //TODO: Add asForumChannel
+ /**
+ * Casts this union to a {@link ForumChannel}.
+ * This method exists for developer discoverability.
+ *
+ * Note: This is effectively equivalent to using the cast operator:
+ *
+ *
+ * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
+ * whether you can call this method in addition to normal instanceof checks:
+ * //These are the same!
+ * ForumChannel channel = union.asForumChannel();
+ * ForumChannel channel2 = (ForumChannel) union;
+ *
channel instanceof ForumChannel
+ *
+ * @throws IllegalStateException
+ * If the channel represented by this union is not actually a {@link ForumChannel}.
+ *
+ * @return The channel as a {@link ForumChannel}
+ */
+ @Nonnull
+ ForumChannel asForumChannel();
/**
* Casts this union to a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}.
diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/MessageChannelUnion.java b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/MessageChannelUnion.java
index 61be48620f..faa2a08830 100644
--- a/src/main/java/net/dv8tion/jda/api/entities/channel/unions/MessageChannelUnion.java
+++ b/src/main/java/net/dv8tion/jda/api/entities/channel/unions/MessageChannelUnion.java
@@ -33,6 +33,7 @@
*
*
diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java
new file mode 100644
index 0000000000..d171be2f0e
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.events.channel.forum;
+
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
+
+import javax.annotation.Nonnull;
+import java.util.Collection;
+
+/**
+ * Indicates that a new {@link ForumTag} was added to a {@link ForumChannel}.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ */
+public class ForumTagAddEvent extends GenericForumTagEvent
+{
+ public ForumTagAddEvent(@Nonnull JDA api, long responseNumber, @Nonnull ForumChannel channel, @Nonnull ForumTag tag)
+ {
+ super(api, responseNumber, channel, tag);
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java
new file mode 100644
index 0000000000..10f49db772
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.events.channel.forum;
+
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
+
+import javax.annotation.Nonnull;
+import java.util.Collection;
+
+/**
+ * Indicates that a {@link ForumTag} was removed from a {@link ForumChannel}.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ */
+public class ForumTagRemoveEvent extends GenericForumTagEvent
+{
+ public ForumTagRemoveEvent(@Nonnull JDA api, long responseNumber, @Nonnull ForumChannel channel, @Nonnull ForumTag tag)
+ {
+ super(api, responseNumber, channel, tag);
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java
new file mode 100644
index 0000000000..64f3ff4cba
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.events.channel.forum;
+
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
+import net.dv8tion.jda.api.events.Event;
+
+import javax.annotation.Nonnull;
+import java.util.Collection;
+
+/**
+ * Abstraction of all tags relating to {@link ForumTag} changes (excluding {@link ThreadChannel#getAppliedTags()}).
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ */
+public abstract class GenericForumTagEvent extends Event
+{
+ protected final ForumChannel channel;
+ protected final ForumTag tag;
+
+ public GenericForumTagEvent(@Nonnull JDA api, long responseNumber, @Nonnull ForumChannel channel, @Nonnull ForumTag tag)
+ {
+ super(api, responseNumber);
+ this.channel = channel;
+ this.tag = tag;
+ }
+
+ /**
+ * The {@link ForumChannel} which has been updated.
+ *
+ * @return The {@link ForumChannel}
+ */
+ @Nonnull
+ public ForumChannel getChannel()
+ {
+ return channel;
+ }
+
+ /**
+ * The {@link ForumTag} that was affected by this event
+ *
+ * @return The {@link ForumTag}
+ */
+ @Nonnull
+ public ForumTag getTag()
+ {
+ return tag;
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java
new file mode 100644
index 0000000000..26b77296cf
--- /dev/null
+++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dv8tion.jda.api.events.channel.forum.update;
+
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
+import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+/**
+ * Indicates that the {@link ForumTag#getEmoji() emoji} of a {@link ForumTag} changed.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ *
+ *
+ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled.
+ * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default.
+ *
+ * @param >
+{
+ public ChannelUpdateAppliedTagsEvent(@Nonnull JDA api, long responseNumber, @Nonnull ThreadChannel channel, @Nonnull List
TextChannel names may only be populated with alphanumeric (with underscore and dash).
*
*
Provide {@code 0} to disable slowmode.
+ *
+ *
Having {@link Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
+ * {@link Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
+ * grants immunity to slowmode.
+ *
+ *
+ * {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannels} use this to limit how many posts a user can create.
+ * The client refers to this as the post slowmode.
+ *
+ *
+ * @param slowmode
+ * The new slowmode
+ *
+ * @throws IllegalArgumentException
+ * If the provided slowmode is negative or greater than {@value ISlowmodeChannel#MAX_SLOWMODE}
+ *
+ * @return ChannelManager for chaining convenience
+ *
+ * @see net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel#getSlowmode()
+ */
+ @Nonnull
+ @CheckReturnValue
+ M setSlowmode(int slowmode);
+}
diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/CategoryManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/CategoryManager.java
index be36dc80cd..53ef66a487 100644
--- a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/CategoryManager.java
+++ b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/CategoryManager.java
@@ -20,6 +20,14 @@
import net.dv8tion.jda.api.managers.channel.attribute.IPermissionContainerManager;
import net.dv8tion.jda.api.managers.channel.attribute.IPositionableChannelManager;
+/**
+ * Manager providing methods to modify a {@link Category}.
+ *
+ * {@code
+ * manager.setName("Cool People Only").queue();
+ * }
+ */
public interface CategoryManager extends
IPermissionContainerManager{@code
+ * manager.setName("gamer-forum")
+ * .setSlowmode(10)
+ * .setTopic("Welcome to the gamer forum!")
+ * .queue();
+ * manager.reset(ChannelManager.NSFW | ChannelManager.NAME)
+ * .setName("gamer-forum-nsfw")
+ * .setNSFW(true)
+ * .queue();
+ * }
+ */
+public interface ForumChannelManager extends
+ StandardGuildChannelManager
If true, all new posts must have at least one tag.
+ *
+ * @param requireTag
+ * The new tag requirement state for the selected {@link ForumChannel}
+ *
+ * @return ChannelManager for chaining convenience.
+ *
+ * @see ForumChannel#isTagRequired()
+ */
+ @Nonnull
+ @CheckReturnValue
+ ForumChannelManager setTagRequired(boolean requireTag);
+
+ /**
+ * Sets the available tags of the selected {@link ForumChannel}.
+ *
Tags will be ordered based on the provided list order.
+ *
+ * {@code
+ * List
+ *
+ * @param tags
+ * The new available tags in the desired order.
+ *
+ * @throws IllegalArgumentException
+ * If the provided list is null or contains null elements
+ *
+ * @return ChannelManager for chaining convenience
+ *
+ * @see ForumChannel#getAvailableTags()
+ */
+ @Nonnull
+ @CheckReturnValue
+ ForumChannelManager setAvailableTags(@Nonnull List extends BaseForumTag> tags);
+
+ /**
+ * Sets the default reaction emoji of the selected {@link ForumChannel}.
+ *
This does not support custom emoji from other guilds.
+ *
+ * @param emoji
+ * The new default reaction emoji, or null to unset.
+ *
+ * @return ChannelManager for chaining convenience
+ *
+ * @see ForumChannel#getDefaultReaction()
+ */
+ @Nonnull
+ @CheckReturnValue
+ ForumChannelManager setDefaultReaction(@Nullable Emoji emoji);
+}
diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/NewsChannelManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/NewsChannelManager.java
index 2af8a5373c..286408d4f8 100644
--- a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/NewsChannelManager.java
+++ b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/NewsChannelManager.java
@@ -25,6 +25,16 @@
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
+/**
+ * Manager providing methods to modify a {@link NewsChannel}.
+ *
+ * {@code
+ * manager.setName("no-more-news")
+ * .setType(ChannelType.TEXT) // Changes channel type to TextChannel
+ * .queue();
+ * }
+ */
public interface NewsChannelManager extends StandardGuildMessageChannelManager{@code
+ * manager.setName("School Presentations")
+ * .setBitrate(96000)
+ * .queue();
+ * }
+ */
public interface StageChannelManager extends
AudioChannelManager
Provide {@code 0} to reset the slowmode of the {@link TextChannel TextChannel}
- *
- *
Having {@link Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
- * {@link Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
- * grants immunity to slowmode.
- *
- * @see net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel#getSlowmode()
- *
- * @param slowmode
- * The new slowmode for the selected {@link TextChannel TextChannel}
- *
- * @throws IllegalArgumentException
- * If the provided slowmode is negative or greater than {@link TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}
- *
- * @return ChannelManager for chaining convenience
- */
- @Nonnull
- @CheckReturnValue
- TextChannelManager setSlowmode(int slowmode);
-
/**
* Converts the selected channel to a different {@link ChannelType}.
*
diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/ThreadChannelManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/ThreadChannelManager.java
index fc56d6e02c..ed309ee3d3 100644
--- a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/ThreadChannelManager.java
+++ b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/ThreadChannelManager.java
@@ -16,8 +16,17 @@
package net.dv8tion.jda.api.managers.channel.concrete;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
+import net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake;
import net.dv8tion.jda.api.managers.channel.ChannelManager;
+import net.dv8tion.jda.api.managers.channel.attribute.ISlowmodeChannelManager;
+import net.dv8tion.jda.internal.utils.Checks;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nonnull;
+import java.util.Arrays;
+import java.util.Collection;
/**
* Manager providing functionality common for all {@link ThreadChannel ThreadChannels}.
@@ -37,32 +46,8 @@
* @see ThreadChannel#getManager()
* @see ThreadChannel
*/
-public interface ThreadChannelManager extends ChannelManager
Provide {@code 0} to reset the slowmode of the {@link ThreadChannel}.
- *
- *
Having {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
- * {@link net.dv8tion.jda.api.Permission#MANAGE_CHANNEL MANAGE_CHANNEL} permission also
- * grants immunity to slowmode.
- *
- * @param slowmode
- * The new slowmode, in seconds, for the selected {@link ThreadChannel}
- *
- * @return this ThreadChannelManager for chaining convenience
- *
- * @throws IllegalArgumentException
- * If the provided slowmode is negative or greater than {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel#MAX_SLOWMODE TextChannel.MAX_SLOWMODE}
- *
- * @see ThreadChannel#getSlowmode()
- */
- ThreadChannelManager setSlowmode(int slowmode);
-
/**
* Sets the inactive time before autoarchiving of this ThreadChannel.
*
@@ -75,7 +60,9 @@ public interface ThreadChannelManager extends ChannelManager
This is only applicable to public threads inside forum channels. The tags must be from the forum channel.
+ * You can get the list of available tags with {@link ForumChannel#getAvailableTags()}.
+ *
+ * @param tags
+ * The new tags for the thread
+ *
+ * @throws IllegalStateException
+ * If the thread is not a forum post
+ * @throws IllegalArgumentException
+ *
+ *
+ *
+ * @return this ThreadChannelManager for chaining convenience.
+ */
+ @Nonnull
+ @CheckReturnValue
+ ThreadChannelManager setAppliedTags(@Nonnull Collection extends ForumTagSnowflake> tags);
+
+ /**
+ * Sets the applied {@link net.dv8tion.jda.api.entities.channel.forums.ForumTag ForumTags} for this forum post thread.
+ *
This is only applicable to public threads inside forum channels. The tags must be from the forum channel.
+ * You can get the list of available tags with {@link ForumChannel#getAvailableTags()}.
+ *
+ * @param tags
+ * The new tags for the thread
+ *
+ * @throws IllegalStateException
+ * If the thread is not a forum post
+ * @throws IllegalArgumentException
+ *
+ *
+ *
+ * @return this ThreadChannelManager for chaining convenience.
+ */
+ @Nonnull
+ @CheckReturnValue
+ default ThreadChannelManager setAppliedTags(@Nonnull ForumTagSnowflake... tags)
+ {
+ Checks.noneNull(tags, "Tags");
+ return setAppliedTags(Arrays.asList(tags));
+ }
}
diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/middleman/StandardGuildMessageChannelManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/middleman/StandardGuildMessageChannelManager.java
index 94b792a86f..4c283e357a 100644
--- a/src/main/java/net/dv8tion/jda/api/managers/channel/middleman/StandardGuildMessageChannelManager.java
+++ b/src/main/java/net/dv8tion/jda/api/managers/channel/middleman/StandardGuildMessageChannelManager.java
@@ -45,14 +45,14 @@ public interface StandardGuildMessageChannelManager
This is primarily used to hide threads after the provided time of inactivity.
+ * Threads are automatically archived after 7 days of inactivity regardless.
+ *
+ * @param autoArchiveDuration
+ * The new archive inactivity duration (which hides the thread)
+ *
+ * @throws IllegalArgumentException
+ * If the provided duration is null
+ *
+ * @return The current action, for chaining convenience
+ */
+ @Nonnull
+ @CheckReturnValue
+ R setAutoArchiveDuration(@Nonnull ThreadChannel.AutoArchiveDuration autoArchiveDuration);
+}
diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java
index ba6d7b8b37..56861c48dc 100644
--- a/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java
+++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java
@@ -80,12 +80,18 @@ public interface AuditableRestAction
Having {@link net.dv8tion.jda.api.Permission#MESSAGE_MANAGE MESSAGE_MANAGE} or
@@ -190,9 +185,9 @@ public interface ChannelAction
This does not support custom emoji from other guilds.
+ *
+ * @param emoji
+ * The new default reaction emoji, or null to unset.
+ *
+ * @return The current ChannelAction, for chaining convenience
+ *
+ * @see ForumChannel#getDefaultReaction()
+ */
+ @Nonnull
+ @CheckReturnValue
+ ChannelAction
Tags will be ordered based on the provided list order.
+ *
+ *
This simply fixes the return types to be the concrete implementation instead of the base interface.
+ *
+ * @param
Some forums require setting at least one tag.
+ *
+ * @param tags
+ * Up to {@value ForumChannel#MAX_POST_TAGS} tags to apply
+ *
+ * @throws IllegalArgumentException
+ * If null is provided or more than {@value ForumChannel#MAX_POST_TAGS} tags are provided,
+ * or if at least one is {@link ForumChannel#isTagRequired() required} and none were provided.
+ *
+ * @return The current ForumPostAction for chaining convenience
+ *
+ * @see ForumTagSnowflake#fromId(long)
+ */
+ @Nonnull
+ ForumPostAction setTags(@Nonnull Collection extends ForumTagSnowflake> tags);
+
+ /**
+ * Configures that tags which should be applied to the new post.
+ *
Some forums require setting at least one tag.
+ *
+ * @param tags
+ * Up to {@value ForumChannel#MAX_POST_TAGS} tags to apply
+ *
+ * @throws IllegalArgumentException
+ * If null is provided or more than {@value ForumChannel#MAX_POST_TAGS} tags are provided,
+ * or if at least one is {@link ForumChannel#isTagRequired() required} and none were provided.
+ *
+ * @return The current ForumPostAction for chaining convenience
+ *
+ * @see ForumTagSnowflake#fromId(long)
+ */
+ @Nonnull
+ default ForumPostAction setTags(@Nonnull ForumTagSnowflake... tags)
+ {
+ Checks.noneNull(tags, "Tags");
+ return setTags(Arrays.asList(tags));
+ }
+}
diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/ThreadChannelAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/ThreadChannelAction.java
index 2edd79fb26..8c35b00a95 100644
--- a/src/main/java/net/dv8tion/jda/api/requests/restaction/ThreadChannelAction.java
+++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/ThreadChannelAction.java
@@ -16,17 +16,11 @@
package net.dv8tion.jda.api.requests.restaction;
-import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
-import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BooleanSupplier;
/**
* Extension of {@link net.dv8tion.jda.api.requests.RestAction RestAction} specifically
@@ -39,56 +33,8 @@
* @see net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer#createThreadChannel(String, long)
* @see net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer#createThreadChannel(String, String)
*/
-public interface ThreadChannelAction extends AuditableRestAction
If there is no shard with an id that matches the provided one, this will return {@code null}.
diff --git a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java
index 436ebfa0bf..d5934739ec 100644
--- a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java
+++ b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java
@@ -19,6 +19,8 @@
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
+import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.requests.GatewayIntent;
import javax.annotation.Nonnull;
@@ -70,6 +72,10 @@ public enum CacheFlag
* Enables cache for {@link Role#getTags()}
*/
ROLE_TAGS,
+ /**
+ * Enables cache for {@link ForumChannel#getAvailableTagCache()} and {@link ThreadChannel#getAppliedTags()}
+ */
+ FORUM_TAGS,
/**
* Enables cache for {@link Member#getOnlineStatus()}
*
This is enabled implicitly by {@link #ACTIVITY} and {@link #CLIENT_STATUS}.
diff --git a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheView.java b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheView.java
index 6a75cac639..ef50e5271b 100644
--- a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheView.java
+++ b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheView.java
@@ -140,7 +140,6 @@ default void forEachUnordered(@Nonnull final Consumer super T> action)
*
* @see #acceptStream(Consumer)
*/
- @Nullable
default > retrieveActiveThreads()
threadObj.put("member", selfThreadMemberObj);
}
- ThreadChannel thread = builder.createThreadChannel(threadObj, this.getIdLong());
- list.add(thread);
+ try
+ {
+ ThreadChannel thread = builder.createThreadChannel(threadObj, this.getIdLong());
+ list.add(thread);
+ }
+ catch (Exception e)
+ {
+ if (EntityBuilder.MISSING_CHANNEL.equals(e.getMessage()))
+ EntityBuilder.LOG.debug("Discarding thread without cached parent channel. JSON: {}", threadObj);
+ else
+ EntityBuilder.LOG.warn("Failed to create thread channel. JSON: {}", threadObj, e);
+ }
}
return Collections.unmodifiableList(list);
@@ -1634,60 +1664,52 @@ public AuditableRestAction