Creating types for slash command options.

Hello guys. I have been search the Internet about this, with little to no success, so I thought I'd ask here.

Is it possible to provide custom types for my slash command options. For example, I can restrict the interaction and command name and commandNames respectively, and also the
type
like this:

import type { ApplicationCommandType, ChatInputApplicationCommandData, CommandInteraction } from 'discord.js';

type ISlashChatCommandNames = 'foo' | 'bar';

export interface ISlashChatCommandData extends ChatInputApplicationCommandData {
    name: ISlashChatCommandNames;
    type: ApplicationCommandType.ChatInput,
}

export interface ISlashChatCommandInteraction extends CommandInteraction {
    commandName: ISlashChatCommandNames;
    commandType: ApplicationCommandType.ChatInput,
}


ISlashChatCommandData is used for the slash command builder andISlashChatCommandInteraction is for when the users are interacting with the bot.
Was this page helpful?