Skip to content

Commit

Permalink
feat(APIGuildForumChannel): update and add missing features (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo-tem committed Sep 25, 2022
1 parent 2dc3fd0 commit 0f118d3
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 24 deletions.
70 changes: 68 additions & 2 deletions deno/payloads/v10/channel.ts
Expand Up @@ -108,7 +108,7 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
*/
default_auto_archive_duration?: ThreadAutoArchiveDuration;
/**
* The channel topic (0-1024 characters)
* The channel topic (0-4096 characters for forum channels, 0-1024 characters for all others)
*/
topic?: string | null;
/**
Expand Down Expand Up @@ -230,9 +230,67 @@ export interface APIThreadChannel
* Similar to `message_count` on message creation, but won't decrement when a message is deleted
*/
total_message_sent?: number;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
*/
applied_tags: Snowflake[];
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;
/**
* https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure
*/
export interface APIGuildForumTag {
/**
* The id of the tag
*/
id: Snowflake;
/**
* The name of the tag (0-20 characters)
*/
name: string;
/**
* Whether this tag can only be added to or removed from threads by a member with the `MANAGE_THREADS` permission
*/
moderated: boolean;
/**
* The id of a guild's custom emoji
*/
emoji_id: Snowflake | null;
/**
* The unicode character of the emoji
*/
emoji_name: string | null;
}

/**
* https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure
*/
export interface APIGuildForumDefaultReactionEmoji {
/**
* The id of a guild's custom emoji
*/
emoji_id: Snowflake | null;
/**
* The unicode character of the emoji
*/
emoji_name: string | null;
}

export interface APIGuildForumChannel extends APIGuildTextChannel<ChannelType.GuildForum> {
/**
* The set of tags that can be used in a forum channel
*/
available_tags: APIGuildForumTag[];
/**
* The initial `rate_limit_per_user` to set on newly created threads in a channel.
* This field is copied to the thread at creation time and does not live update
*/
default_thread_rate_limit_per_user?: number;
/**
* The emoji to show in the add reaction button on a thread in a forum channel
*/
default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
Expand Down Expand Up @@ -1429,7 +1487,15 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
/**
* This thread is pinned to the top of its parent forum channel
*/
Pinned = 1 << 1,
/**
* Whether a tag is required to be specified when creating a thread in a forum channel.
* Tags are specified in the `applied_tags` field
*/
RequireTag = 1 << 4,
}

/**
Expand Down
68 changes: 67 additions & 1 deletion deno/payloads/v9/channel.ts
Expand Up @@ -230,9 +230,67 @@ export interface APIThreadChannel
* Similar to `message_count` on message creation, but won't decrement when a message is deleted
*/
total_message_sent?: number;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
*/
applied_tags: Snowflake[];
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;
/**
* https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure
*/
export interface APIGuildForumTag {
/**
* The id of the tag
*/
id: Snowflake;
/**
* The name of the tag (0-20 characters)
*/
name: string;
/**
* Whether this tag can only be added to or removed from threads by a member with the `MANAGE_THREADS` permission
*/
moderated: boolean;
/**
* The id of a guild's custom emoji
*/
emoji_id: Snowflake | null;
/**
* The unicode character of the emoji
*/
emoji_name: string | null;
}

/**
* https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure
*/
export interface APIGuildForumDefaultReactionEmoji {
/**
* The id of a guild's custom emoji
*/
emoji_id: Snowflake | null;
/**
* The unicode character of the emoji
*/
emoji_name: string | null;
}

export interface APIGuildForumChannel extends APIGuildTextChannel<ChannelType.GuildForum> {
/**
* The set of tags that can be used in a forum channel
*/
available_tags: APIGuildForumTag[];
/**
* The initial `rate_limit_per_user` to set on newly created threads in a channel.
* This field is copied to the thread at creation time and does not live update
*/
default_thread_rate_limit_per_user?: number;
/**
* The emoji to show in the add reaction button on a thread in a forum channel
*/
default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
Expand Down Expand Up @@ -1428,7 +1486,15 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
/**
* This thread is pinned to the top of its parent forum channel
*/
Pinned = 1 << 1,
/**
* Whether a tag is required to be specified when creating a thread in a forum channel.
* Tags are specified in the `applied_tags` field
*/
RequireTag = 1 << 4,
}

/**
Expand Down
10 changes: 9 additions & 1 deletion deno/rest/common.ts
Expand Up @@ -137,9 +137,14 @@ export enum RESTJSONErrorCodes {

ApplicationInteractionFailedToSend = 40043,

CannotSendAMessageInAForumChannel = 40058,

InteractionHasAlreadyBeenAcknowledged = 40060,
TagNamesMustBeUnique,

ThereAreNoTagsAvailableThatCanBeSetByNonModerators = 40066,
TagRequiredToCreateAForumPostInThisChannel,

MissingAccess = 50001,
InvalidAccountType,
CannotExecuteActionOnDMChannel,
Expand Down Expand Up @@ -246,7 +251,10 @@ export enum RESTJSONErrorCodes {
MessageWasBlockedByAutomaticModeration = 200000,
TitleWasBlockedByAutomaticModeration,

WebhooksCanOnlyCreateThreadsInForumChannels = 220003,
WebhooksPostedToForumChannelsMustHaveAThreadNameOrThreadId = 220001,
WebhooksPostedToForumChannelsCannotHaveBothAThreadNameAndThreadId,
WebhooksCanOnlyCreateThreadsInForumChannels,
WebhookServicesCannotBeUsedInForumChannels,

MessageBlockedByHarmfulLinksFilter = 240000,
}
Expand Down
33 changes: 29 additions & 4 deletions deno/rest/v10/channel.ts
Expand Up @@ -19,6 +19,8 @@ import type {
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
APIGuildForumTag,
APIGuildForumDefaultReactionEmoji,
} from '../../payloads/v10/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';

Expand Down Expand Up @@ -56,23 +58,23 @@ export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropert
*/
position?: number | null;
/**
* 0-1024 character channel topic
* 0-1024 character channel topic (0-4096 characters for forum channels)
*
* Channel types: text, news
* Channel types: text, news, forum
*/
topic?: string | null;
/**
* Whether the channel is nsfw
*
* Channel types: text, voice, news
* Channel types: text, voice, news, forum
*/
nsfw?: boolean | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`,
* are unaffected
*
* Channel types: text, newsThread, publicThread, privateThread
* Channel types: text, newsThread, publicThread, privateThread, forum
*/
rate_limit_per_user?: number | null;
/**
Expand Down Expand Up @@ -141,6 +143,25 @@ export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropert
* Channel types: privateThread
*/
invitable?: boolean;
/**
* The set of tags that can be used in a forum channel
*
* Channel types: forum
*/
available_tags?: APIGuildForumTag[];
/**
* The emoji to show in the add reaction button on a thread in a forum channel
*
* Channel types: forum
*/
default_reaction_emoji?: APIGuildForumDefaultReactionEmoji;
/**
* The initial `rate_limit_per_user` to set on newly created threads in a channel.
* This field is copied to the thread at creation time and does not live update
*
* Channel types: text, forum
*/
default_thread_rate_limit_per_user?: number | null;
}>;

/**
Expand Down Expand Up @@ -589,6 +610,10 @@ export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThr
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
*/
applied_tags?: Snowflake[];
};

/**
Expand Down
2 changes: 2 additions & 0 deletions deno/rest/v10/guild.ts
Expand Up @@ -53,6 +53,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
| 'default_reaction_emoji'
| 'available_tags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
Expand Down
33 changes: 29 additions & 4 deletions deno/rest/v9/channel.ts
Expand Up @@ -19,6 +19,8 @@ import type {
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
APIGuildForumTag,
APIGuildForumDefaultReactionEmoji,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';

Expand Down Expand Up @@ -56,23 +58,23 @@ export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropert
*/
position?: number | null;
/**
* 0-1024 character channel topic
* 0-1024 character channel topic (0-4096 characters for forum channels)
*
* Channel types: text, news
* Channel types: text, news, forum
*/
topic?: string | null;
/**
* Whether the channel is nsfw
*
* Channel types: text, voice, news
* Channel types: text, voice, news, forum
*/
nsfw?: boolean | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`,
* are unaffected
*
* Channel types: text, newsThread, publicThread, privateThread
* Channel types: text, newsThread, publicThread, privateThread, forum
*/
rate_limit_per_user?: number | null;
/**
Expand Down Expand Up @@ -141,6 +143,25 @@ export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropert
* Channel types: privateThread
*/
invitable?: boolean;
/**
* The set of tags that can be used in a forum channel
*
* Channel types: forum
*/
available_tags?: APIGuildForumTag[];
/**
* The emoji to show in the add reaction button on a thread in a forum channel
*
* Channel types: forum
*/
default_reaction_emoji?: APIGuildForumDefaultReactionEmoji;
/**
* The initial `rate_limit_per_user` to set on newly created threads in a channel.
* This field is copied to the thread at creation time and does not live update
*
* Channel types: text, forum
*/
default_thread_rate_limit_per_user?: number | null;
}>;

/**
Expand Down Expand Up @@ -603,6 +624,10 @@ export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThr
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
*/
applied_tags?: Snowflake[];
};

/**
Expand Down
2 changes: 2 additions & 0 deletions deno/rest/v9/guild.ts
Expand Up @@ -53,6 +53,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
| 'default_reaction_emoji'
| 'available_tags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
Expand Down

1 comment on commit 0f118d3

@vercel
Copy link

@vercel vercel bot commented on 0f118d3 Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.