Concepts

Warning

This page is still a work in progress.

Intents

Intents are a security feature discord has. This tells discord what your bot’s intentions are.

You can find a list of intents here.

Note

There are two types of intents:

  • Standard : can be passed with no additional settings or configurations.
  • Privileged : have to be toggled in your bot’s settings before passing. For bots within 100+ guilds you also need to apply for said intents after verification.

Learn more about gateway intents

Commands

Discm has two base types of commands:

  • Text
  • Slash

Text Commands

Text commands are not uploaded to discord for deployment, as all it does is look for messages, read the contents, and determine if it is a command or if it is just a message.

Text commands require GuildMessages and MessageContent intents.

Prefixes help determine which messages are commands and which aren’t, your bot’s prefix can be set via DiscmClient#prefix.

Text commands can accept arguments, however it is not as easy as slash command arguments, as you would have to parse everything yourself.

Tip

Discm automatically parses arguments for you, but if you wish to parse yourself, do not define DiscmCommand<"text">#options

Slash Commands

Slash commands have to be uploaded to discord for deployment, which is automatically handled by discm.

They can either be deployed globally (meaning every guild the bot is a member of) or privately by specifing the guild id to deploy to (if the bot is a member of that guild).

To deploy commands privately set DiscmClient#global to false. It is set to true by default.

You can also delay the deployment of every command or individual commands via DiscmClient#delayDeploy or DiscmCommand#delayDeploy.

These commands will not deploy until DiscmClient#deploy or DiscmClient#deployCommand are called.

Note

If DiscmClient#global is set to false, you need to provide either a singular guild id, or an array of guild ids to the login function.

The login function on DiscmClient overloads discord.js’s Client#login

// filename: lib/classes/Client.ts /** * Logs the bot into discord. Emits the `ready` event once the client successfully logs in. * This method also automatically deploys all slash commands. * If {@link DiscmClient.delayDeploy delayed deploy} is set to true, the commands will not deploy. * @param token The token of the bot account to log in to. Can be obtained via {@link https://discord.com/developers discord developer portal}. * @param guildId The id of a guild (or a list of guild ids) to privately deploy commands to. If the bot is not a global bot, the parameter is not required. * @returns Promise<string> */ public override async login(token: string, guildId?: string | string[]) { if (guildId === undefined && !this.delayedDeploy && !this.global) throw new DeployError( 'Cannot privately deploy with no provided guild ids.' ); await super.login(token); if (!this.delayedDeploy) await deploy(this, guildId); return token; }
typescript
undefined

Slash commands can also accept arguments, which are automatically parsed for you by discord.

Events

Events tell us when something in the guild happens, like when a message is sent or deleted, when a member joins or leaves the guild, or when someone uses a slash command.

Discm listens to InteractionCreate and MessageCreate to detect and run commands, you can still listen to these commands manually, however it will be ran after the discm code is ran.

Learn more about gateway events