diff --git a/__tests__/interactions/SlashCommands/SlashCommands.test.ts b/__tests__/interactions/SlashCommands/SlashCommands.test.ts index 6f0d75a2..40f69642 100644 --- a/__tests__/interactions/SlashCommands/SlashCommands.test.ts +++ b/__tests__/interactions/SlashCommands/SlashCommands.test.ts @@ -8,6 +8,7 @@ import { SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, + SlashCommandAttachmentOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, @@ -25,6 +26,7 @@ const getBooleanOption = () => new SlashCommandBooleanOption().setName('owo').se const getUserOption = () => new SlashCommandUserOption().setName('owo').setDescription('Testing 123'); const getChannelOption = () => new SlashCommandChannelOption().setName('owo').setDescription('Testing 123'); const getRoleOption = () => new SlashCommandRoleOption().setName('owo').setDescription('Testing 123'); +const getAttachmentOption = () => new SlashCommandAttachmentOption().setName('owo').setDescription('Testing 123'); const getMentionableOption = () => new SlashCommandMentionableOption().setName('owo').setDescription('Testing 123'); const getSubcommandGroup = () => new SlashCommandSubcommandGroupBuilder().setName('owo').setDescription('Testing 123'); const getSubcommand = () => new SlashCommandSubcommandBuilder().setName('owo').setDescription('Testing 123'); @@ -286,6 +288,8 @@ describe('Slash Commands', () => { expect(() => getBuilder().addRoleOption(getRoleOption())).not.toThrowError(); + expect(() => getBuilder().addAttachmentOption(getAttachmentOption())).not.toThrowError(); + expect(() => getBuilder().addMentionableOption(getMentionableOption())).not.toThrowError(); }); diff --git a/src/index.ts b/src/index.ts index fa51ade9..e0b9e8f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ export * from './interactions/slashCommands/options/integer'; export * from './interactions/slashCommands/options/mentionable'; export * from './interactions/slashCommands/options/number'; export * from './interactions/slashCommands/options/role'; +export * from './interactions/slashCommands/options/attachment'; export * from './interactions/slashCommands/options/string'; export * from './interactions/slashCommands/options/user'; diff --git a/src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts b/src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts index 6d3c4be4..f23898fd 100644 --- a/src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts +++ b/src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts @@ -6,6 +6,7 @@ import { SlashCommandIntegerOption } from '../options/integer'; import { SlashCommandMentionableOption } from '../options/mentionable'; import { SlashCommandNumberOption } from '../options/number'; import { SlashCommandRoleOption } from '../options/role'; +import { SlashCommandAttachmentOption } from '../options/attachment'; import { SlashCommandStringOption } from '../options/string'; import { SlashCommandUserOption } from '../options/user'; import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder'; @@ -53,6 +54,17 @@ export class SharedSlashCommandOptions { return this._sharedAddOptionMethod(input, SlashCommandRoleOption); } + /** + * Adds an attachment option + * + * @param input A function that returns an option builder, or an already built builder + */ + public addAttachmentOption( + input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption), + ) { + return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption); + } + /** * Adds a mentionable option * diff --git a/src/interactions/slashCommands/options/attachment.ts b/src/interactions/slashCommands/options/attachment.ts new file mode 100644 index 00000000..9f28abb1 --- /dev/null +++ b/src/interactions/slashCommands/options/attachment.ts @@ -0,0 +1,10 @@ +import { ApplicationCommandOptionType } from 'discord-api-types/v9'; +import { SlashCommandOptionBase } from '../mixins/CommandOptionBase'; + +export class SlashCommandAttachmentOption extends SlashCommandOptionBase { + public override readonly type = ApplicationCommandOptionType.Attachment as const; + + public constructor() { + super(ApplicationCommandOptionType.Attachment); + } +}