Skip to content

Introduction to Commands

The primary entry point for any Discord bot is commands. In Seyfert, commands are defined using TypeScript decorators, making it easier to specify their properties, options, middlewares, and subcommands.

Declaring a Command

All commands in Seyfert are class-based, and each class extends the base Command class.

Additionally, the name and description are mandatory properties for every command. Below is a list of possible properties that can be used with the @Declare decorator:

import {
function Declare(declare: CommandDeclareOptions): <T extends {
new (...args: any[]): object;
}>(target: T) => {
new (...args: any[]): {
name: string;
nsfw: boolean | undefined;
props: ExtraProps | undefined;
contexts: InteractionContextType[];
integrationTypes: ApplicationIntegrationType[];
defaultMemberPermissions: bigint | undefined;
botPermissions: bigint | undefined;
description: string;
type: ApplicationCommandType;
guildId?: string[];
ignore?: IgnoreCommand;
aliases?: string[];
handler?: EntryPointCommandHandlerType;
};
} & T
Declare
,
class Command
Command
,
enum IgnoreCommand
IgnoreCommand
} from 'seyfert';
@
function Declare(declare: CommandDeclareOptions): <T extends {
new (...args: any[]): object;
}>(target: T) => {
new (...args: any[]): {
name: string;
nsfw: boolean | undefined;
props: ExtraProps | undefined;
contexts: InteractionContextType[];
integrationTypes: ApplicationIntegrationType[];
defaultMemberPermissions: bigint | undefined;
botPermissions: bigint | undefined;
description: string;
type: ApplicationCommandType;
guildId?: string[];
ignore?: IgnoreCommand;
aliases?: string[];
handler?: EntryPointCommandHandlerType;
};
} & T
Declare
({
name: string
name
: 'your-command',
description: string
description
: 'A description for this command',
// Properties to pass as metadata
props: {}
props
: {},
// List of permissions required by the member
defaultMemberPermissions: "Administrator"[]
defaultMemberPermissions
: ['Administrator'],
// List of permissions required by the bot
botPermissions: "ManageGuild"[]
botPermissions
: ['ManageGuild'],
// List of server IDs to register the command
guildId: string[]
guildId
: ['100000'],
// Determines if the command is NSFW
nsfw: false
nsfw
: false,
// List of alternate names for the command (text commands)
aliases: string[]
aliases
: ['an-alias'],
// Identifies the installation types the command supports,
// default is server-only
integrationTypes: ("GuildInstall" | "UserInstall")[]
integrationTypes
: ['GuildInstall', 'UserInstall'],
// Specifies where a command can be used
contexts: ("Guild" | "BotDM" | "PrivateChannel")[]
contexts
: ['BotDM', 'Guild', 'PrivateChannel'],
// Defines whether to ignore the execution of the command in slash
// or text-message versions
ignore: IgnoreCommand.Slash
ignore
:
enum IgnoreCommand
IgnoreCommand
.
function (enum member) IgnoreCommand.Slash = 0
Slash
,
Message
Slash
// Sets the type of command:
/// type: ApplicationCommandType.User
})
class
class MyCommand
MyCommand
extends
class Command
Command
{}