From fbf54c4fc93de1366b7328db49dbea94cfc40476 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sat, 10 Dec 2022 12:23:04 -0600 Subject: [PATCH] feat: channel rest types --- .../followAnnouncementChannel.ts | 4 +- .../editChannelPermissionOverrides.ts | 3 +- .../helpers/channels/editChannelPositions.ts | 12 +++--- .../channels/forums/createForumThread.ts | 3 +- packages/types/src/discord.ts | 43 +++++++++++++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/packages/rest/src/helpers/channels/announcements/followAnnouncementChannel.ts b/packages/rest/src/helpers/channels/announcements/followAnnouncementChannel.ts index 8620ff117..6bdf146cf 100644 --- a/packages/rest/src/helpers/channels/announcements/followAnnouncementChannel.ts +++ b/packages/rest/src/helpers/channels/announcements/followAnnouncementChannel.ts @@ -1,4 +1,4 @@ -import type { BigString, DiscordFollowedChannel } from '@discordeno/types' +import type { BigString, DiscordFollowedChannel, DiscordFollowAnnouncementChannel } from '@discordeno/types' import type { RestManager } from '../../../restManager.js' /** @@ -27,7 +27,7 @@ export async function followAnnouncementChannel ( rest.constants.routes.CHANNEL_FOLLOW(sourceChannelId), { webhook_channel_id: targetChannelId - } + } as DiscordFollowAnnouncementChannel ) return result diff --git a/packages/rest/src/helpers/channels/editChannelPermissionOverrides.ts b/packages/rest/src/helpers/channels/editChannelPermissionOverrides.ts index 280309ab0..31c164d53 100644 --- a/packages/rest/src/helpers/channels/editChannelPermissionOverrides.ts +++ b/packages/rest/src/helpers/channels/editChannelPermissionOverrides.ts @@ -1,5 +1,6 @@ import type { BigString, + DiscordEditChannelPermissionOverridesOptions, OverwriteReadable, WithReason } from '@discordeno/types' @@ -36,7 +37,7 @@ export async function editChannelPermissionOverrides ( deny: options.deny ? calculateBits(options.deny) : '0', type: options.type, reason: options.reason - } + } as DiscordEditChannelPermissionOverridesOptions ) } diff --git a/packages/rest/src/helpers/channels/editChannelPositions.ts b/packages/rest/src/helpers/channels/editChannelPositions.ts index 7c43d0106..cf789ed3c 100644 --- a/packages/rest/src/helpers/channels/editChannelPositions.ts +++ b/packages/rest/src/helpers/channels/editChannelPositions.ts @@ -1,4 +1,4 @@ -import type { BigString } from '@discordeno/types' +import type { BigString, DiscordModifyGuildChannelPositions } from '@discordeno/types' import type { RestManager } from '../../restManager.js' export const swapChannels = editChannelPositions @@ -31,22 +31,22 @@ export async function editChannelPositions ( 'PATCH', rest.constants.routes.GUILD_CHANNELS(guildId), channelPositions.map((channelPosition) => ({ - id: channelPosition.id, + id: channelPosition.id.toString(), position: channelPosition.position, lock_positions: channelPosition.lockPositions, - parent_id: channelPosition.parentId - })) + parent_id: channelPosition.parentId?.toString() + })) as DiscordModifyGuildChannelPositions[] ) } /** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ export interface ModifyGuildChannelPositions { /** Channel id */ - id: string + id: BigString /** Sorting position of the channel */ position: number | null /** Syncs the permission overwrites with the new parent, if moving to a new category */ lockPositions?: boolean | null /** The new parent ID for the channel that is moved */ - parentId?: string | null + parentId?: BigString | null } diff --git a/packages/rest/src/helpers/channels/forums/createForumThread.ts b/packages/rest/src/helpers/channels/forums/createForumThread.ts index 43f753f80..1f70f221a 100644 --- a/packages/rest/src/helpers/channels/forums/createForumThread.ts +++ b/packages/rest/src/helpers/channels/forums/createForumThread.ts @@ -2,6 +2,7 @@ import type { AllowedMentions, BigString, DiscordChannel, + DiscordCreateForumPostWithMessage, FileContent, MessageComponents, SnakeToCamelCaseNested, @@ -60,7 +61,7 @@ export async function createForumThread ( components: options.components?.map((component) => rest.transformers.reverse.component(rest, component) ) - } + } as DiscordCreateForumPostWithMessage ) return snakeToCamelCaseNested(result) diff --git a/packages/types/src/discord.ts b/packages/types/src/discord.ts index 6653258e5..348d98cad 100644 --- a/packages/types/src/discord.ts +++ b/packages/types/src/discord.ts @@ -2948,3 +2948,46 @@ export interface DiscordStartThreadWithoutMessage { /** whether non-moderators can add other non-moderators to a thread; only available when creating a private thread */ invitable?: boolean } + +export interface CreateForumPostWithMessage { + /** 1-100 character thread name */ + name: string + /** Duration in minutes to automatically archive the thread after recent activity */ + auto_archive_duration: 60 | 1440 | 4320 | 10080 + /** Amount of seconds a user has to wait before sending another message (0-21600) */ + rate_limit_per_user?: number | null + /** The message contents (up to 2000 characters) */ + content?: string + /** Embedded `rich` content (up to 6000 characters) */ + embeds?: DiscordEmbed[] + /** Allowed mentions for the message */ + allowed_mentions?: DiscordAllowedMentions + /** The components you would like to have sent in this message */ + components?: DiscordMessageComponents +} + +export interface DiscordFollowAnnouncementChannel { + /** The id of the channel to send announcements to. */ + webhook_channel_id: string +} + +export interface DiscordEditChannelPermissionOverridesOptions { + /** Permission bit set */ + allow: string + /** Permission bit set */ + deny: string + /** Either 0 (role) or 1 (member) */ + type: OverwriteTypes +} + +/** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */ +export interface DiscordModifyGuildChannelPositions { + /** Channel id */ + id: string + /** Sorting position of the channel */ + position: number | null + /** Syncs the permission overwrites with the new parent, if moving to a new category */ + lock_positions?: boolean | null + /** The new parent ID for the channel that is moved */ + parent_id?: string | null +} \ No newline at end of file