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

feat(APIGuildForumChannel): update and add missing features #575

Merged
merged 23 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a20d8f4
feat(APIGuildForumChannel): update and add missing features
Mateo-tem Aug 29, 2022
42ce2ef
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Aug 29, 2022
0138dff
fix: update descriptions
Mateo-tem Aug 29, 2022
57c88d2
fix: update descriptions (deno)
Mateo-tem Aug 29, 2022
a32530e
fix: style issues
Mateo-tem Aug 29, 2022
6cdde63
feat: add support for v9
Mateo-tem Aug 29, 2022
7c01de6
feat(ChannelFlags): add RequireTag
Mateo-tem Aug 29, 2022
0983e62
fix: remove template field of forum channel
Mateo-tem Aug 29, 2022
6fd9e28
feat(RESTJSONErrorCodes): add forum missing errors
Mateo-tem Aug 29, 2022
5493b51
fix: update description of emoji_name
Mateo-tem Aug 29, 2022
2cf5518
chore: sync with upstream PR
Mateo-tem Aug 30, 2022
8a8ef0e
feat(ChannelFlags): add descriptions
Mateo-tem Aug 30, 2022
c9cb30e
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Aug 31, 2022
bf0b2de
fix(RESTJSONErrorCodes): name of error 220002
Mateo-tem Aug 31, 2022
e857e43
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Sep 4, 2022
daafa55
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Sep 6, 2022
04fc1d1
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Sep 11, 2022
aa6c966
fix: emoji_id field is now nullable
Mateo-tem Sep 11, 2022
2847b0b
feat: add docs links
Mateo-tem Sep 11, 2022
7714099
Merge branch 'main' into feat/update-forum-docs
Mateo-tem Sep 18, 2022
272bf8b
feat: add default_sort_order
Mateo-tem Sep 18, 2022
debb341
fix: revert adding default_sort_order
Mateo-tem Sep 21, 2022
d6bbc00
feat: add missing properties to create a guild channel
Mateo-tem Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 68 additions & 2 deletions deno/payloads/v10/channel.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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[];
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export type APIGuildCreatePartialChannel = StrictPartial<
| 'rtc_region'
| 'video_quality_mode'
| 'flags'
| 'default_reaction_emoji'
| 'available_tags'
>
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
Expand Down