Interface ChatInputCommandOptions<I>

Represents a client command configuration object

interface ChatInputCommandOptions<I> {
    aliasOf?: null | CommandType;
    aliases?: string[];
    category?: null | string;
    clientPerms?: PermissionResolvable[];
    cooldown?: CommandThrottleOptions;
    data: APISlashCommandData;
    deferReply?: boolean;
    disabled?: boolean;
    global?: boolean;
    guildOnly?: boolean;
    isEphemeral?: boolean;
    middleware?: CommandMiddlewareOptions<I, CommandMiddlewareContext<I>>;
    nsfw?: boolean;
    permLevel?: PermLevel | "User" | "Moderator" | "Administrator" | "Server Owner" | "Bot Administrator" | "Developer" | "Bot Owner";
    requiredResourceIds?: Partial<IRequiredResources>;
    run: RunFunction<I>;
    userPerms?: PermissionResolvable[];
}

Type Parameters

  • I extends ChatInputCommandInteraction = ChatInputCommandInteraction

Hierarchy (view full)

Implemented by

Properties

aliasOf?: null | CommandType

Represents the command this command is an alias of

aliases?: string[]

Represents a list of commands that are identical to the original command, with different names

category?: null | string

This command's category, if omitted, the command's origin file's parent folder name will be parsed and used

Default

'file parent folder name'
clientPerms?: PermissionResolvable[]

Permissions required by the client to execute the command

Command cooldown/throttling configuration to apply to this command

Note: This is NOT persistent, for that, you should use your own persistent cooldown middleware

Command data to send off to the Discord API, resolved by builder

deferReply?: boolean

Defers the reply to run interactions internally if possible

disabled?: boolean

Is the command currently disabled? If so - it won't be available anywhere. Late API updates (users that see the command in their command overview after the API data update) are accounted for

Default

false
global?: boolean

Indicates if this command is available globally. If NODE_ENV is production it will default to true. If NODE_ENV is anything else, it will default to false.

guildOnly?: boolean

Is this command only available in guilds/servers, or also in DMs? You should use InteractionUtils.requireAvailableGuild in your command/controller to assert the interaction type

Default

true
isEphemeral?: boolean

Tries to (defer, edit, followUp, etc.) reply ephemerally if possible

Middleware for this command

Example

import { ChatInputMiddlewareFunction } from '../middleware/CommandMiddleware';

const requireDJRole: ChatInputMiddlewareFunction = async ({
next,
client,
command,
interaction,
previousResult,
nextMiddleware,
previousMiddleware,
}) => {
// Do something with available Context
next(); // Only continue to next middleware if next is called
};

export default new ChatInputCommand({
deferReply: true, // You should defer replies ASAP if you're using async middleware
permLevel: PermLevel.Developer,
middleware: [ requireDJRole ],
// OR
middleware: {
preRunChecks: [ requireDJRole ],
// Etc.
}
})
nsfw?: boolean

Is the command Not Safe For Work? If it is, it will only be available in channels that have the NSFW-flag set enabled

Default

false
permLevel?: PermLevel | "User" | "Moderator" | "Administrator" | "Server Owner" | "Bot Administrator" | "Developer" | "Bot Owner"

The permission level required to use the command

If higher than or equal to Administrator, data#setDefaultMemberPermissions(0) is automatically called if not explicitly set

Default

PermLevel.User
requiredResourceIds?: Partial<IRequiredResources>

Represents a list of required resource IDs for a command

These are used to restrict command usage to specific resources, which is especially useful for private bots/functionality

Every parameter represents a oneOf list of IDs of which AT LEAST ONE is required to match If multiple parameters are provided, all of them must match

Internal permissions and availability/constraint checks still apply

  • guilds: Requires command to be executed in one of the provided guilds
  • channels: Requires command to be executed in one of the provided channels
  • roles: Requires command executor to have one of the provided roles
  • users: Requires command executor to be one of the provided users
  • categories: Requires command channel parent to be one of the provided categories

The function to run when the command is executed

userPerms?: PermissionResolvable[]

Permissions required by the user to execute the command