From c76a17365573dad07f947d09d8cd0ab75b6f9950 Mon Sep 17 00:00:00 2001 From: Endy Date: Mon, 8 May 2023 23:33:57 +0700 Subject: [PATCH] Add `channel_types` prop to channel select menu (#3027) https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure --- packages/bot/src/transformers/component.ts | 5 ++++- packages/bot/src/transformers/reverse/component.ts | 1 + packages/bot/src/typings.ts | 9 ++++++--- packages/types/src/discord.ts | 2 ++ packages/types/src/discordeno.ts | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/bot/src/transformers/component.ts b/packages/bot/src/transformers/component.ts index fefc0a6b9..08f71d8b4 100644 --- a/packages/bot/src/transformers/component.ts +++ b/packages/bot/src/transformers/component.ts @@ -1,4 +1,4 @@ -import type { ButtonStyles, MessageComponentTypes, SelectOption, TextStyles } from '@discordeno/types' +import type { ButtonStyles, ChannelTypes, MessageComponentTypes, SelectOption, TextStyles } from '@discordeno/types' import type { Bot } from '../index.js' import type { DiscordComponent } from '../typings.js' @@ -17,6 +17,7 @@ export function transformComponent(bot: Bot, payload: DiscordComponent): Compone } : undefined, url: payload.url, + channelTypes: payload.channel_types, options: payload.options?.map((option) => ({ label: option.label, value: option.value, @@ -68,6 +69,8 @@ export interface Component { } /** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */ url?: string + /** List of channel types to include in a channel select menu options list */ + channelTypes?: ChannelTypes[] /** The choices! Maximum of 25 items. */ options?: SelectOption[] /** A custom placeholder text if nothing is selected. Maximum 150 characters. */ diff --git a/packages/bot/src/transformers/reverse/component.ts b/packages/bot/src/transformers/reverse/component.ts index d28622dc8..7180eaf5b 100644 --- a/packages/bot/src/transformers/reverse/component.ts +++ b/packages/bot/src/transformers/reverse/component.ts @@ -18,6 +18,7 @@ export function transformComponentToDiscordComponent(bot: Bot, payload: Componen } : undefined, url: payload.url, + channel_types: payload.channelTypes, options: payload.options?.map((option) => ({ label: option.label, value: option.value, diff --git a/packages/bot/src/typings.ts b/packages/bot/src/typings.ts index 5582e9af4..46b81621d 100644 --- a/packages/bot/src/typings.ts +++ b/packages/bot/src/typings.ts @@ -2,6 +2,7 @@ import { ApplicationCommandTypes, type AllowedMentions, type ButtonStyles, + type ChannelTypes, type CreateApplicationCommand, type CreateContextApplicationCommand, type DiscordAllowedMentions, @@ -16,13 +17,13 @@ import { type DiscordUser, type FileContent, type InteractionResponseTypes, - type MessageComponents, type MessageComponentTypes, + type MessageComponents, type TextStyles, } from '@discordeno/types' import type * as handlers from './handlers/index.js' -import type { Embed } from './transformers/embed.js' import type { ApplicationCommandOptionChoice } from './transformers/applicationCommandOptionChoice.js' +import type { Embed } from './transformers/embed.js' export function isContextApplicationCommand(command: CreateApplicationCommand): command is CreateContextApplicationCommand { return command.type === ApplicationCommandTypes.Message || command.type === ApplicationCommandTypes.User @@ -69,6 +70,8 @@ export interface DiscordComponent { } /** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */ url?: string + /** List of channel types to include in a channel select menu options list */ + channel_types?: ChannelTypes[] /** The choices! Maximum of 25 items. */ options?: DiscordSelectOption[] /** A custom placeholder text if nothing is selected. Maximum 150 characters. */ @@ -205,7 +208,7 @@ export interface BotGatewayHandlerOptions { export enum MessageFlags { /** Whether this message has been published to subscribed channels (via Channel Following) */ - Crossposted = 1 << 0, + Crossposted = 1 << 0, /** Whether this message originated from a message in another channel (via Channel Following) */ IsCrosspost = 1 << 1, /** Whether do not include any embeds when serializing this message */ diff --git a/packages/types/src/discord.ts b/packages/types/src/discord.ts index 3416cb5f7..ca613ea98 100644 --- a/packages/types/src/discord.ts +++ b/packages/types/src/discord.ts @@ -1134,6 +1134,8 @@ export interface DiscordSelectMenuComponent { min_values?: number /** The maximum number of items that can be selected. Default 1. Between 1-25. */ max_values?: number + /** List of channel types to include in a channel select menu options list */ + channelTypes?: ChannelTypes[] /** The choices! Maximum of 25 items. */ options: DiscordSelectOption[] } diff --git a/packages/types/src/discordeno.ts b/packages/types/src/discordeno.ts index 38c184ea2..8c88d9e2b 100644 --- a/packages/types/src/discordeno.ts +++ b/packages/types/src/discordeno.ts @@ -195,6 +195,8 @@ export interface SelectMenuChannelsComponent { minValues?: number /** The maximum number of items that can be selected. Default 1. Between 1-25. */ maxValues?: number + /** List of channel types to include in the options list */ + channelTypes?: ChannelTypes[] /** Whether or not this select is disabled */ disabled?: boolean }