Skip to content

Commit

Permalink
feat: Add Media channels (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Aug 14, 2023
1 parent 382fb03 commit 138b9f2
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 120 deletions.
34 changes: 26 additions & 8 deletions deno/payloads/v10/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export type TextChannelType =
| ChannelType.GuildText
| ChannelType.GuildForum
| ChannelType.GuildVoice
| ChannelType.GuildStageVoice;
| ChannelType.GuildStageVoice
| ChannelType.GuildMedia;

export type GuildChannelType = Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>;

Expand Down Expand Up @@ -124,7 +125,7 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
*/
default_thread_rate_limit_per_user?: number;
/**
* The channel topic (0-4096 characters for forum channels, 0-1024 characters for all others)
* The channel topic (0-4096 characters for thread-only channels, 0-1024 characters for all others)
*/
topic?: string | null;
}
Expand Down Expand Up @@ -240,7 +241,7 @@ export interface APIThreadChannel
*/
total_message_sent?: number;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
* The IDs of the set of tags that have been applied to a thread in a thread-only channel
*/
applied_tags: Snowflake[];
}
Expand Down Expand Up @@ -317,25 +318,31 @@ export enum ForumLayoutType {
GalleryView,
}

export interface APIGuildForumChannel extends APIGuildTextChannel<ChannelType.GuildForum> {
export interface APIThreadOnlyChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia>
extends APIGuildTextChannel<T> {
/**
* The set of tags that can be used in a forum channel
* The set of tags that can be used in a thread-only channel
*/
available_tags: APIGuildForumTag[];
/**
* The emoji to show in the add reaction button on a thread in a forum channel
* The emoji to show in the add reaction button on a thread in a thread-only channel
*/
default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null;
/**
* The default sort order type used to order posts in a forum channel
* The default sort order type used to order posts in a thread-only channel
*/
default_sort_order: SortOrderType | null;
}

export interface APIGuildForumChannel extends APIThreadOnlyChannel<ChannelType.GuildForum> {
/**
* The default layout type used to display posts in a forum channel. Defaults to `0`, which indicates a layout view has not been set by a channel admin
*/
default_forum_layout: ForumLayoutType;
}

export type APIGuildMediaChannel = APIThreadOnlyChannel<ChannelType.GuildMedia>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -348,7 +355,8 @@ export type APIChannel =
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APIGuildForumChannel;
| APIGuildForumChannel
| APIGuildMediaChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -410,6 +418,12 @@ export enum ChannelType {
* A channel that can only contain threads
*/
GuildForum,
/**
* A channel like forum channels but contains media for server subscriptions
*
* See https://creator-support.discord.com/hc/articles/14346342766743
*/
GuildMedia,

// EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS //

Expand Down Expand Up @@ -1744,6 +1758,10 @@ export enum ChannelFlags {
* @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
*/
IsScheduledForDeletion = 1 << 9,
/**
* Whether media download options are hidden.
*/
HideMediaDownloadOptions = 1 << 15,
}

/**
Expand Down
34 changes: 26 additions & 8 deletions deno/payloads/v9/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export type TextChannelType =
| ChannelType.GuildText
| ChannelType.GuildForum
| ChannelType.GuildVoice
| ChannelType.GuildStageVoice;
| ChannelType.GuildStageVoice
| ChannelType.GuildMedia;

export type GuildChannelType = Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>;

Expand Down Expand Up @@ -124,7 +125,7 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
*/
default_thread_rate_limit_per_user?: number;
/**
* The channel topic (0-1024 characters)
* The channel topic (0-4096 characters for thread-only channels, 0-1024 characters for all others)
*/
topic?: string | null;
}
Expand Down Expand Up @@ -236,7 +237,7 @@ export interface APIThreadChannel
*/
total_message_sent?: number;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
* The IDs of the set of tags that have been applied to a thread in a thread-only channel
*/
applied_tags: Snowflake[];
}
Expand Down Expand Up @@ -313,25 +314,31 @@ export enum ForumLayoutType {
GalleryView,
}

export interface APIGuildForumChannel extends APIGuildTextChannel<ChannelType.GuildForum> {
export interface APIThreadOnlyChannel<T extends ChannelType.GuildForum | ChannelType.GuildMedia>
extends APIGuildTextChannel<T> {
/**
* The set of tags that can be used in a forum channel
* The set of tags that can be used in a thread-only channel
*/
available_tags: APIGuildForumTag[];
/**
* The emoji to show in the add reaction button on a thread in a forum channel
* The emoji to show in the add reaction button on a thread in a thread-only channel
*/
default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null;
/**
* The default sort order type used to order posts in a forum channel
* The default sort order type used to order posts in a thread-only channel
*/
default_sort_order: SortOrderType | null;
}

export interface APIGuildForumChannel extends APIThreadOnlyChannel<ChannelType.GuildForum> {
/**
* The default layout type used to display posts in a forum channel. Defaults to `0`, which indicates a layout view has not been set by a channel admin
*/
default_forum_layout: ForumLayoutType;
}

export type APIGuildMediaChannel = APIThreadOnlyChannel<ChannelType.GuildMedia>;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-structure
*/
Expand All @@ -344,7 +351,8 @@ export type APIChannel =
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APIGuildForumChannel;
| APIGuildForumChannel
| APIGuildMediaChannel;

/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
Expand Down Expand Up @@ -406,6 +414,12 @@ export enum ChannelType {
* A channel that can only contain threads
*/
GuildForum,
/**
* A channel like forum channels but contains media for server subscriptions
*
* See https://creator-support.discord.com/hc/articles/14346342766743
*/
GuildMedia,

// EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS
/**
Expand Down Expand Up @@ -1712,6 +1726,10 @@ export enum ChannelFlags {
* @unstable This channel flag is currently not documented by Discord but has a known value which we will try to keep up to date.
*/
IsScheduledForDeletion = 1 << 9,
/**
* Whether media download options are hidden.
*/
HideMediaDownloadOptions = 1 << 15,
}

/**
Expand Down
49 changes: 27 additions & 22 deletions deno/rest/v10/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
APIGuildForumDefaultReactionEmoji,
SortOrderType,
ForumLayoutType,
ChannelFlags,
} from '../../payloads/v10/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';

Expand Down Expand Up @@ -60,23 +61,23 @@ export interface RESTPatchAPIChannelJSONBody {
*/
position?: number | null | undefined;
/**
* 0-1024 character channel topic (0-4096 characters for forum channels)
* 0-1024 character channel topic (0-4096 characters for thread-only channels)
*
* Channel types: text, news, forum
* Channel types: text, news, forum, media
*/
topic?: string | null | undefined;
/**
* Whether the channel is nsfw
*
* Channel types: text, voice, news, forum
* Channel types: text, voice, news, forum, media
*/
nsfw?: boolean | null | undefined;
/**
* 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, forum
* Channel types: text, newsThread, publicThread, privateThread, forum, media
*/
rate_limit_per_user?: number | null | undefined;
/**
Expand All @@ -100,7 +101,7 @@ export interface RESTPatchAPIChannelJSONBody {
/**
* ID of the new parent category for a channel
*
* Channel types: text, voice, news
* Channel types: text, voice, news, stage, forum, media
*/
parent_id?: Snowflake | null | undefined;
/**
Expand Down Expand Up @@ -136,38 +137,42 @@ export interface RESTPatchAPIChannelJSONBody {
/**
* Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
*
* Channel types: text, news
* Channel types: text, news, forum, media
*/
default_auto_archive_duration?: ThreadAutoArchiveDuration | undefined;
/**
* Whether non-moderators can add other non-moderators to the thread
*
* Channel types: privateThread
* Channel flags combined as a bit field.
*/
invitable?: boolean | undefined;
flags?: ChannelFlags | undefined;
/**
* The set of tags that can be used in a forum channel; limited to 20
* The set of tags that can be used in a thread-only channel; limited to 20
*
* Channel types: forum
* Channel types: forum, media
*/
available_tags?: (Partial<APIGuildForumTag> & Pick<APIGuildForumTag, 'name'>)[] | undefined;
/**
* The emoji to show in the add reaction button on a thread in a forum channel
* Whether non-moderators can add other non-moderators to the thread
*
* Channel types: forum
* Channel types: privateThread
*/
invitable?: boolean | undefined;
/**
* The emoji to show in the add reaction button on a thread in a thread-only channel
*
* Channel types: forum, media
*/
default_reaction_emoji?: APIGuildForumDefaultReactionEmoji | undefined;
/**
* 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: forum
* Channel types: text, forum, media
*/
default_thread_rate_limit_per_user?: number | null | undefined;
/**
* The default sort order type used to order posts in a forum channel
* The default sort order type used to order posts in a thread-only channel
*
* Channel types: forum
* Channel types: forum, media
*/
default_sort_order?: SortOrderType | null | undefined;
/**
Expand Down Expand Up @@ -614,25 +619,25 @@ export interface RESTPostAPIChannelMessagesThreadsJSONBody {
}

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-media-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
* The initial message of the thread
*/
message: RESTPostAPIChannelMessageJSONBody;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel; limited to 5
* The IDs of the set of tags to apply to the thread; limited to 5
*/
applied_tags?: Snowflake[] | undefined;
};

/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
* The initial message of the thread
*/
message: string;
};
Expand Down

0 comments on commit 138b9f2

Please sign in to comment.