From 84cd7165e23338d1f5d8ac5d29bd6256d400eaa0 Mon Sep 17 00:00:00 2001 From: LTS20050703 Date: Tue, 15 Nov 2022 01:31:45 +0700 Subject: [PATCH] types: add SortOrderTypes and default_sort_order to DiscordChannel, helpers: add defaultSortOrder to createChannel and editChannel options (#2582) * types: add SortOrderTypes and default_sort_order to DiscordChannel helpers: add defaultSortOrder to createChannel and editChannel options * Update types/discord.ts Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> --- helpers/channels/createChannel.ts | 5 ++++- helpers/channels/editChannel.ts | 5 ++++- types/discord.ts | 2 ++ types/shared.ts | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/helpers/channels/createChannel.ts b/helpers/channels/createChannel.ts index 394fb5725..d74ef71fa 100644 --- a/helpers/channels/createChannel.ts +++ b/helpers/channels/createChannel.ts @@ -3,7 +3,7 @@ import { WithReason } from "../../mod.ts"; import { Channel } from "../../transformers/channel.ts"; import { DiscordChannel } from "../../types/discord.ts"; import { OverwriteReadable } from "../../types/discordeno.ts"; -import { BigString, ChannelTypes } from "../../types/shared.ts"; +import { BigString, ChannelTypes, SortOrderTypes } from "../../types/shared.ts"; /** * Creates a channel within a guild. @@ -49,6 +49,7 @@ export async function createChannel(bot: Bot, guildId: BigString, options: Creat deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null, })), type: options?.type || ChannelTypes.GuildText, + default_sort_order: options.defaultSortOrder, reason: options.reason, default_auto_archive_duration: options?.defaultAutoArchiveDuration, } @@ -81,4 +82,6 @@ export interface CreateGuildChannel extends WithReason { nsfw?: boolean; /** Default duration (in minutes) that clients (not the API) use for newly created threads in this channel, to determine when to automatically archive the thread after the last activity */ defaultAutoArchiveDuration?: number; + /** the default sort order type used to order posts in forum channels */ + defaultSortOrder?: SortOrderTypes | null; } diff --git a/helpers/channels/editChannel.ts b/helpers/channels/editChannel.ts index 4fb317470..418bf89d8 100644 --- a/helpers/channels/editChannel.ts +++ b/helpers/channels/editChannel.ts @@ -3,7 +3,7 @@ import { WithReason } from "../../mod.ts"; import { Channel } from "../../transformers/channel.ts"; import { DiscordChannel } from "../../types/discord.ts"; import { OverwriteReadable } from "../../types/discordeno.ts"; -import { BigString, ChannelTypes, VideoQualityModes } from "../../types/shared.ts"; +import { BigString, ChannelTypes, SortOrderTypes, VideoQualityModes } from "../../types/shared.ts"; /** * Edits a channel's settings. @@ -103,6 +103,7 @@ export async function editChannel(bot: Bot, channelId: BigString, options: Modif emoji_name: options.defaultReactionEmoji.emojiName, } : undefined, + default_sort_order: options.defaultSortOrder, reason: options.reason, }, ); @@ -223,4 +224,6 @@ export interface ModifyChannel extends WithReason { }; /** 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. */ defaultThreadRateLimitPerUser?: number; + /** the default sort order type used to order posts in forum channels */ + defaultSortOrder?: SortOrderTypes | null; } diff --git a/types/discord.ts b/types/discord.ts index 67d5a040d..414e10597 100644 --- a/types/discord.ts +++ b/types/discord.ts @@ -785,6 +785,8 @@ export interface DiscordChannel { default_reaction_emoji?: DiscordDefaultReactionEmoji | null; /** 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 default sort order type used to order posts in GUILD_FORUM channels. Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin */ + default_sort_order?: SortOrderTypes | null; } /** https://discord.com/developers/docs/topics/gateway#presence-update */ diff --git a/types/shared.ts b/types/shared.ts index 9b4a8c3eb..84a082757 100644 --- a/types/shared.ts +++ b/types/shared.ts @@ -1241,6 +1241,13 @@ export enum InteractionResponseTypes { Modal = 9, } +export enum SortOrderTypes { + /** Sort forum posts by activity */ + LatestActivity, + /** Sort forum posts by creation time (from most recent to oldest) */ + CreationDate, +} + export enum Errors { // Bot Role errors BOTS_HIGHEST_ROLE_TOO_LOW = "BOTS_HIGHEST_ROLE_TOO_LOW",