Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for forum channels #2184

Merged
merged 79 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b9065ee
Add initial support for forum channels
MinnDevelopment Jul 19, 2022
5644266
Fix some copy-paste issues
MinnDevelopment Jul 19, 2022
0cabd2d
Update union type list
MinnDevelopment Jul 19, 2022
a97bc91
Add ForumChannel#createForumPost
MinnDevelopment Jul 19, 2022
d3d3719
Implement ForumChannelManagerImpl
MinnDevelopment Jul 20, 2022
eb78683
Merge remote-tracking branch 'origin/master' into feature/forums
MinnDevelopment Jul 20, 2022
8765433
Improve checks in ChannelActionImpl
MinnDevelopment Jul 20, 2022
fd4d312
Remove tags
MinnDevelopment Jul 20, 2022
45ae0ca
Add throws docs for other overload
MinnDevelopment Jul 20, 2022
581f56f
Add docs for permission checks
MinnDevelopment Jul 20, 2022
48ba485
Add new message count logic
MinnDevelopment Jul 26, 2022
26d4428
Fix typo
MinnDevelopment Jul 26, 2022
9768352
Add forums to Guild#getChannels
MinnDevelopment Jul 31, 2022
9418b61
Add Category#getForumChannels
MinnDevelopment Jul 31, 2022
9aaf5f7
Clear forum channel cache on invalidate
MinnDevelopment Jul 31, 2022
a30040e
Reduce code duplication in createXChannel
MinnDevelopment Jul 31, 2022
3919196
Improve some documentation
MinnDevelopment Jul 31, 2022
628e2f7
Add Category#createNewsChannel
MinnDevelopment Jul 31, 2022
b4739f6
Add missing docs for IThreadContainer
MinnDevelopment Jul 31, 2022
cb4ed95
Improve handling of thread parents
MinnDevelopment Aug 8, 2022
0f37bff
Update docs for ThreadChannel
MinnDevelopment Aug 8, 2022
bc34c48
Update more docs of thread channel
MinnDevelopment Aug 8, 2022
3d2f7e9
Make getForumChannelCache return the cache instead of null
MinnDevelopment Aug 8, 2022
e25b4e2
Merge remote-tracking branch 'origin/master' into feature/forums
MinnDevelopment Aug 16, 2022
a689e3e
Add ForumPostAction
MinnDevelopment Aug 16, 2022
32cfbd6
Update some docs
MinnDevelopment Aug 16, 2022
11517ad
Update src/main/java/net/dv8tion/jda/api/entities/Guild.java
MinnDevelopment Aug 16, 2022
8770569
Fix javadoc errors
MinnDevelopment Aug 16, 2022
346c3a4
Add missing break
MinnDevelopment Aug 30, 2022
6b28ff9
Add another missing break
MinnDevelopment Aug 30, 2022
d7ebf59
Add missing docs
MinnDevelopment Aug 30, 2022
3940806
Update docs for archives and add some more missing docs
MinnDevelopment Aug 30, 2022
6e4d5f1
Add handling for forum topic length
MinnDevelopment Aug 30, 2022
a336739
Add basic support for applying tags
MinnDevelopment Aug 30, 2022
bed9213
Add check for max tags
MinnDevelopment Aug 30, 2022
f8c44fb
Merge remote-tracking branch 'origin/master' into feature/forums
MinnDevelopment Aug 30, 2022
c86264e
Add support for applied tags on threads
MinnDevelopment Aug 30, 2022
f3fbf18
Add handling for tag updates
MinnDevelopment Aug 30, 2022
9160ed7
Add cache flag for forum tags
MinnDevelopment Aug 31, 2022
a1d3c46
Handle default thread slowmode
MinnDevelopment Sep 1, 2022
dfccd62
Handle channel flags for forums
MinnDevelopment Sep 1, 2022
ae85f75
Handle thread flags
MinnDevelopment Sep 1, 2022
d5a4961
Merge remote-tracking branch 'origin/master' into feature/forums
MinnDevelopment Sep 14, 2022
191acca
Implement tag ordering by position
MinnDevelopment Sep 14, 2022
bca3972
Implement tag emoji and setting available tags on managers
MinnDevelopment Sep 14, 2022
2082c83
Add support to manage available tags
MinnDevelopment Sep 14, 2022
0e1906a
Add webhook support to forums
MinnDevelopment Sep 14, 2022
64162cc
Add convenience getters and support modifying tags
MinnDevelopment Sep 14, 2022
f7ace19
Support changing channel flags
MinnDevelopment Sep 14, 2022
22fbb46
Add support for default reactions
MinnDevelopment Sep 15, 2022
47ac2c1
Add missing docs
MinnDevelopment Sep 15, 2022
935116c
Fix some docs
MinnDevelopment Sep 15, 2022
2f6b4e4
Remove todo and update exception message
MinnDevelopment Sep 15, 2022
854a759
Add missing docs to BaseForumTag
MinnDevelopment Sep 15, 2022
f324cb1
Fix annotation
MinnDevelopment Sep 15, 2022
30edf96
Use FluentRestAction interface
MinnDevelopment Sep 15, 2022
4ea02aa
Make ChannelUpdateAppliedTagsEvent cache independent
MinnDevelopment Sep 15, 2022
35a60c7
Update ChannelManager#setTopic
MinnDevelopment Sep 15, 2022
a3a4ddd
Update exception message for setAppliedTags
MinnDevelopment Sep 15, 2022
31ecfa0
Move checkTypes into Checks class
MinnDevelopment Sep 15, 2022
be4b40c
Rename create thread routes
MinnDevelopment Sep 15, 2022
c2f104b
Update src/main/java/net/dv8tion/jda/api/events/channel/update/Channe…
MinnDevelopment Sep 15, 2022
1f9c577
Update src/main/java/net/dv8tion/jda/internal/handle/MessageDeleteHan…
MinnDevelopment Sep 15, 2022
9c777e4
Add forum tag events
MinnDevelopment Sep 16, 2022
7d09a14
Fix constructors
MinnDevelopment Sep 16, 2022
f8c3cbc
Introduce ISlowmodeChannel attribute interface
MinnDevelopment Sep 17, 2022
af69976
Add varargs version of setAppliedTags
MinnDevelopment Sep 17, 2022
81adfa9
Add FluentAuditableRestAction
MinnDevelopment Sep 17, 2022
bab2947
Rename isRequireTag to isTagRequired
MinnDevelopment Sep 17, 2022
e02dea1
Add more accessors for forum tags
MinnDevelopment Sep 17, 2022
50f23a0
Add event docs
MinnDevelopment Sep 17, 2022
8a90838
Use constants more
MinnDevelopment Sep 17, 2022
0d0fb2b
Update the slowmode supported types and remove outdated todo comment
MinnDevelopment Sep 17, 2022
a22fb78
Add missing setters to ChannelAction
MinnDevelopment Sep 17, 2022
fce8eaa
Add docs for ISlowmodeChannelManager
MinnDevelopment Sep 19, 2022
9951047
Mention CacheFlag in getAvailableTagCache
MinnDevelopment Sep 19, 2022
f7c97f9
Add type checks to ChannelAction
MinnDevelopment Sep 19, 2022
0aa796b
Add default sort oder
MinnDevelopment Sep 19, 2022
051ee54
Missed event
MinnDevelopment Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -207,6 +214,13 @@ public enum AuditLogKey
*/
CHANNEL_NAME("name"),

/**
* Change of the {@link Channel#getFlags() flags} value.
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_FLAGS("flags"),

/**
* Change of the {@link ICategorizableChannel#getParentCategory()} ICategorizable.getParentCategory()} value.
* <br>Use with {@link net.dv8tion.jda.api.entities.Guild#getCategoryById(String) Guild.getCategoryById(String)}
Expand All @@ -224,13 +238,26 @@ public enum AuditLogKey
CHANNEL_TOPIC("topic"),

/**
* Change of the {@link TextChannel#getSlowmode() TextChannel.getSlowmode()} value.
* <br>Only for {@link ChannelType#TEXT ChannelType.TEXT}
* Change of the {@link ISlowmodeChannel#getSlowmode()} value.
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_SLOWMODE("rate_limit_per_user"),

/**
* Change of the {@link IThreadContainer#getDefaultThreadSlowmode()} value.
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_DEFAULT_THREAD_SLOWMODE("default_thread_rate_limit_per_user"),

/**
* Change of the {@link ForumChannel#getDefaultReaction()} value.
*
* <p>Expected type: <b>Map</b> containing {@code emoji_id} and {@code emoji_name}
*/
CHANNEL_DEFAULT_REACTION_EMOJI("default_reaction_emoji"),

/**
* Change of the {@link VoiceChannel#getBitrate() VoiceChannel.getBitrate()} value.
* <br>Only for {@link ChannelType#VOICE ChannelType.VOICE}
Expand Down Expand Up @@ -277,6 +304,13 @@ public enum AuditLogKey
*/
CHANNEL_OVERRIDES("permission_overwrites"),

/**
* The available tags of this {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannel}.
*
* <p>Expected type: <b>List{@literal <Map<String, Object>>}</b>
*/
CHANNEL_AVAILABLE_TAGS("available_tags"),

// THREADS

/**
Expand All @@ -287,10 +321,16 @@ public enum AuditLogKey
THREAD_NAME("name"),

/**
* Change of the {@link ThreadChannel#getSlowmode() ThreadChannel.getSlowmode()} value.
* Change of the {@link ISlowmodeChannel#getSlowmode()} value.
*
* <p>Expected type: <b>Integer</b>
*
* @deprecated Use {@link #CHANNEL_SLOWMODE} instead
*/
@Deprecated
@ForRemoval
@DeprecatedSince("5.0.0")
@ReplaceWith("CHANNEL_SLOWMODE")
THREAD_SLOWMODE("rate_limit_per_user"),

/**
Expand Down Expand Up @@ -322,6 +362,13 @@ public enum AuditLogKey
*/
THREAD_INVITABLE("invitable"),

/**
* The applied tags of this {@link ThreadChannel}, given that it is a forum post.
*
* <p>Expected type: <b>List{@literal <String>}</b>
*/
THREAD_APPLIED_TAGS("applied_tags"),

// STAGE_INSTANCE

/**
Expand Down
133 changes: 99 additions & 34 deletions src/main/java/net/dv8tion/jda/api/entities/Guild.java

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/channel/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import java.util.EnumSet;
import java.util.FormattableFlags;
import java.util.Formatter;

Expand All @@ -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.
* <br>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<ChannelFlag> getFlags()
{
return EnumSet.noneOf(ChannelFlag.class);
}

/**
* The human readable name of this channel.
*
Expand Down Expand Up @@ -71,6 +89,7 @@ public interface Channel extends IMentionable
@CheckReturnValue
RestAction<Void> delete();

@Nonnull
@Override
default String getAsMention()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import net.dv8tion.jda.api.audit.AuditLogKey;
import net.dv8tion.jda.api.entities.Guild;
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.concrete.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildMessageChannel;
Expand Down Expand Up @@ -56,10 +59,17 @@ public enum ChannelField
*/
NAME("name", AuditLogKey.CHANNEL_NAME),

/**
* The flags of the channel.
*
* @see Channel#getFlags()
*/
FLAGS("flags", AuditLogKey.CHANNEL_FLAGS),

/**
* The {@link Category parent} of the channel.
*
* Limited to {@link net.dv8tion.jda.api.entities.channel.attribute.ICategorizableChannel Categorizable Channels} (and implementations).
* <p>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()
*/
Expand All @@ -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),
MinnDevelopment marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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}.
* <p>Limited to {@link NewsChannel NewsChannels} and {@link TextChannel TextChannels}.
*
* @see StandardGuildMessageChannel#getTopic()
*/
Expand All @@ -89,34 +112,42 @@ public enum ChannelField
/**
* The NSFW state of the channel.
*
* Limited to {@link StandardGuildMessageChannel StandardGuildMessageChannels} (and implementations).
* <p>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.
* <br>This defines the minimum time between message sends.
*
* Limited to {@link TextChannel Text Channels}.
* <p>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.
* <p>For standard channels this is between 8000 and 96000.
*
* VIP servers extend this limit to 128000.
* <p>VIP servers extend this limit to 128000.
* <br>
* The bitrates of boost tiers may be found in {@link Guild.BoostTier the boost tiers}.
*
* Limited to {@link AudioChannel Audio Channels}.
* <p>Limited to {@link AudioChannel Audio Channels}.
*
* @see AudioChannel#getBitrate()
*/
Expand All @@ -125,7 +156,7 @@ public enum ChannelField
/**
* The region of the channel.
*
* Limited to {@link AudioChannel Audio Channels}.
* <p>Limited to {@link AudioChannel Audio Channels}.
*
* @see AudioChannel#getRegion()
* @see net.dv8tion.jda.api.Region
Expand All @@ -135,7 +166,7 @@ public enum ChannelField
/**
* The maximum user count of this channel.
*
* Limited to {@link VoiceChannel Voice Channels}.
* <p>Limited to {@link VoiceChannel Voice Channels}.
*
* @see VoiceChannel#getUserLimit()
*/
Expand All @@ -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.
* <p>If the thread is inactive for this long, it becomes auto-archived.
*
* Limited to {@link ThreadChannel Thread Channels}.
* <p>Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#getAutoArchiveDuration()
* @see ThreadChannel.AutoArchiveDuration
Expand All @@ -159,9 +190,9 @@ public enum ChannelField
/**
* The archive state of this channel.
*
* If the channel is archived, this is true.
* <p>If the channel is archived, this is true.
*
* Limited to {@link ThreadChannel Thread Channels}.
* <p>Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#isArchived()
*/
Expand All @@ -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:
* <p>This timestamp will be updated when any of the following happen:
* <ul>
* <li>The channel is archived</li>
* <li>The channel is unarchived</li>
Expand All @@ -179,17 +210,16 @@ public enum ChannelField
*
* Limited to {@link ThreadChannel Thread Channels}.
*
*
* @see ThreadChannel#getTimeArchiveInfoLastModified()
*/
ARCHIVED_TIMESTAMP("archiveTimestamp", null),

/**
* The locked state of this channel.
*
* If the channel is locked, this is true.
* <p>If the channel is locked, this is true.
*
* Limited to {@link ThreadChannel Thread Channels}.
* <p>Limited to {@link ThreadChannel Thread Channels}.
*
* @see ThreadChannel#isLocked()
*/
Expand All @@ -198,13 +228,23 @@ public enum ChannelField
/**
* The invite state of this channel.
*
* If the channel is invitable, this is true.
* <p>If the channel is invitable, this is true.
*
* Limited to {@link ThreadChannel Thread Channels}.
* <p>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.
*
* <p>Limited to {@link ThreadChannel ThreadChannels} inside {@link ForumChannel ForumChannels}
*
* @see ThreadChannel#getAppliedTags()
*/
APPLIED_TAGS("applied_tags", AuditLogKey.THREAD_APPLIED_TAGS),

;

private final String fieldName;
Expand All @@ -228,6 +268,8 @@ public AuditLogKey getAuditLogKey()
return auditLogKey;
}

@Nonnull
@Override
public String toString()
{
return "ChannelField." + name() + '(' + fieldName + ')';
Expand Down
Loading