Skip to content

Commit

Permalink
feat(APIGuildForum): add support for forums, part 1 (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitor <milagre.vitor@gmail.com>
  • Loading branch information
suneettipirneni and vvito7 committed Apr 10, 2022
1 parent 69079ee commit bf08484
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 8 deletions.
20 changes: 18 additions & 2 deletions deno/payloads/v10/channel.ts
Expand Up @@ -37,6 +37,7 @@ export interface APIPartialChannel {
*/
export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel {
type: T;
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
Expand All @@ -47,7 +48,8 @@ export type TextChannelType =
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText;
| ChannelType.GuildText
| ChannelType.GuildForum;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand Down Expand Up @@ -223,6 +225,8 @@ export interface APIThreadChannel
last_message_id?: Snowflake | null;
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -234,7 +238,8 @@ export type APIChannel =
| APIVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel;
| APINewsChannel
| APIGuildForumChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -292,6 +297,10 @@ export enum ChannelType {
* See https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ
*/
GuildDirectory,
/**
* A channel that can only contain threads
*/
GuildForum,
}

export enum VideoQualityMode {
Expand Down Expand Up @@ -1358,6 +1367,13 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
Pinned = 1 << 1,
}

/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
Expand Down
20 changes: 18 additions & 2 deletions deno/payloads/v9/channel.ts
Expand Up @@ -37,6 +37,7 @@ export interface APIPartialChannel {
*/
export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel {
type: T;
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
Expand All @@ -47,7 +48,8 @@ export type TextChannelType =
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText;
| ChannelType.GuildText
| ChannelType.GuildForum;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand Down Expand Up @@ -223,6 +225,8 @@ export interface APIThreadChannel
last_message_id?: Snowflake | null;
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -234,7 +238,8 @@ export type APIChannel =
| APIVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel;
| APINewsChannel
| APIGuildForumChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -292,6 +297,10 @@ export enum ChannelType {
* See https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ
*/
GuildDirectory,
/**
* A channel that can only contain threads
*/
GuildForum,
}

export enum VideoQualityMode {
Expand Down Expand Up @@ -1358,6 +1367,13 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
Pinned = 1 << 1,
}

/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
Expand Down
5 changes: 5 additions & 0 deletions deno/rest/common.ts
Expand Up @@ -55,6 +55,8 @@ export enum RESTJSONErrorCodes {
UnknownGuildScheduledEvent,
UnknownGuildScheduledEventUser,

UnknownTag = 10087,

BotsCannotUseThisEndpoint = 20001,
OnlyBotsCanUseThisEndpoint,

Expand Down Expand Up @@ -111,6 +113,8 @@ export enum RESTJSONErrorCodes {
MaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042,

MaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
MaximumNumberOfPinnedThreadsInForumHasBeenReached,
MaximumNumberOfTagsInForumHasBeenReached,

Unauthorized = 40001,
VerifyYourAccount,
Expand All @@ -126,6 +130,7 @@ export enum RESTJSONErrorCodes {
ApplicationCommandWithThatNameAlreadyExists = 40041,

InteractionHasAlreadyBeenAcknowledged = 40060,
TagNamesMustBeUnique,

MissingAccess = 50001,
InvalidAccountType,
Expand Down
11 changes: 11 additions & 0 deletions deno/rest/v10/channel.ts
Expand Up @@ -581,6 +581,17 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
rate_limit_per_user?: number;
}>;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
Expand Down
11 changes: 11 additions & 0 deletions deno/rest/v9/channel.ts
Expand Up @@ -595,6 +595,17 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
rate_limit_per_user?: number;
}>;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
Expand Down
20 changes: 18 additions & 2 deletions payloads/v10/channel.ts
Expand Up @@ -37,6 +37,7 @@ export interface APIPartialChannel {
*/
export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel {
type: T;
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
Expand All @@ -47,7 +48,8 @@ export type TextChannelType =
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText;
| ChannelType.GuildText
| ChannelType.GuildForum;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand Down Expand Up @@ -223,6 +225,8 @@ export interface APIThreadChannel
last_message_id?: Snowflake | null;
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -234,7 +238,8 @@ export type APIChannel =
| APIVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel;
| APINewsChannel
| APIGuildForumChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -292,6 +297,10 @@ export enum ChannelType {
* See https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ
*/
GuildDirectory,
/**
* A channel that can only contain threads
*/
GuildForum,
}

export enum VideoQualityMode {
Expand Down Expand Up @@ -1358,6 +1367,13 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
Pinned = 1 << 1,
}

/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
Expand Down
20 changes: 18 additions & 2 deletions payloads/v9/channel.ts
Expand Up @@ -37,6 +37,7 @@ export interface APIPartialChannel {
*/
export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel {
type: T;
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
Expand All @@ -47,7 +48,8 @@ export type TextChannelType =
| ChannelType.GuildPublicThread
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText;
| ChannelType.GuildText
| ChannelType.GuildForum;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand Down Expand Up @@ -223,6 +225,8 @@ export interface APIThreadChannel
last_message_id?: Snowflake | null;
}

export type APIGuildForumChannel = APIGuildTextChannel<ChannelType.GuildForum>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -234,7 +238,8 @@ export type APIChannel =
| APIVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel;
| APINewsChannel
| APIGuildForumChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -292,6 +297,10 @@ export enum ChannelType {
* See https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ
*/
GuildDirectory,
/**
* A channel that can only contain threads
*/
GuildForum,
}

export enum VideoQualityMode {
Expand Down Expand Up @@ -1358,6 +1367,13 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
required?: boolean;
}

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-flags
*/
export enum ChannelFlags {
Pinned = 1 << 1,
}

/**
* https://discord.com/developers/docs/interactions/message-components#message-components
*/
Expand Down
5 changes: 5 additions & 0 deletions rest/common.ts
Expand Up @@ -55,6 +55,8 @@ export enum RESTJSONErrorCodes {
UnknownGuildScheduledEvent,
UnknownGuildScheduledEventUser,

UnknownTag = 10087,

BotsCannotUseThisEndpoint = 20001,
OnlyBotsCanUseThisEndpoint,

Expand Down Expand Up @@ -111,6 +113,8 @@ export enum RESTJSONErrorCodes {
MaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042,

MaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
MaximumNumberOfPinnedThreadsInForumHasBeenReached,
MaximumNumberOfTagsInForumHasBeenReached,

Unauthorized = 40001,
VerifyYourAccount,
Expand All @@ -126,6 +130,7 @@ export enum RESTJSONErrorCodes {
ApplicationCommandWithThatNameAlreadyExists = 40041,

InteractionHasAlreadyBeenAcknowledged = 40060,
TagNamesMustBeUnique,

MissingAccess = 50001,
InvalidAccountType,
Expand Down
11 changes: 11 additions & 0 deletions rest/v10/channel.ts
Expand Up @@ -581,6 +581,17 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
rate_limit_per_user?: number;
}>;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
Expand Down
11 changes: 11 additions & 0 deletions rest/v9/channel.ts
Expand Up @@ -595,6 +595,17 @@ export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUn
rate_limit_per_user?: number;
}>;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
RESTPostAPIChannelMessageJSONBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessageFormDataBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
Expand Down

0 comments on commit bf08484

Please sign in to comment.