From 16e5ff0e1f5f5a15ea7ff051d045fd1b6e87866c Mon Sep 17 00:00:00 2001 From: paring Date: Sat, 9 Mar 2024 20:04:57 +0900 Subject: [PATCH] feat: attachment support --- .../ApplicationCommandExtension.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/applicationCommand/ApplicationCommandExtension.ts b/src/applicationCommand/ApplicationCommandExtension.ts index 5399467..da29250 100644 --- a/src/applicationCommand/ApplicationCommandExtension.ts +++ b/src/applicationCommand/ApplicationCommandExtension.ts @@ -9,7 +9,7 @@ import type { Snowflake, ApplicationCommandOptionData, } from 'discord.js' -import { ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js' +import { Attachment, ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js' import { ApplicationCommandOptionType, ApplicationCommandType } from 'discord-api-types/v10' import { ApplicationCommandComponent } from './ApplicationCommand' import { ApplicationCommandOption } from './ApplicationCommandOption' @@ -118,7 +118,15 @@ export class ApplicationCommandExtension extends CTSExtension { } } - value = i.options.get(decorator.options.name, false)?.value + switch (decorator.options.type) { + case ApplicationCommandOptionType.Attachment: + value = i.options.getAttachment(decorator.options.name, decorator.options.required) + break + default: + value = i.options.get(decorator.options.name)?.value + break + } + break } } @@ -373,4 +381,10 @@ export class ApplicationCommandExtension extends CTSExtension { async commandInteraction(i: UserContextMenuCommandInteraction) { return i } + + @argConverter({ + component: ApplicationCommandComponent, + type: Attachment, + }) + async attachment() {} }