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(APIGuildForum): add support for forums, part 1 #398

Merged
merged 8 commits into from
Apr 10, 2022
20 changes: 18 additions & 2 deletions deno/payloads/v10/channel.ts
Original file line number Diff line number Diff line change
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>;
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
Original file line number Diff line number Diff line change
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
| APIGuildCategoryChannel;
suneettipirneni marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
Original file line number Diff line number Diff line change
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,
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved

MissingAccess = 50001,
InvalidAccountType,
Expand Down
6 changes: 6 additions & 0 deletions deno/rest/v10/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,12 @@ 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-with-message
*/
Expand Down
6 changes: 6 additions & 0 deletions deno/rest/v9/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ 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 &
suneettipirneni marked this conversation as resolved.
Show resolved Hide resolved
RESTPostAPIChannelMessageJSONBody;

/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
Expand Down
20 changes: 18 additions & 2 deletions payloads/v10/channel.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
| APIGuildCategoryChannel;
suneettipirneni marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions rest/v10/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,12 @@ 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-with-message
*/
Expand Down
6 changes: 6 additions & 0 deletions rest/v9/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ 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-with-message
*/
Expand Down