Archived
2.1 KiB
2.1 KiB
CommandBot
A Discord.js based framework that makes creating Discord bots easy and fast.
Table of contents
Installation
System requirements
- Node.js 16.6.0 or newer
- npm or yarn package manager
Creating a project
Registering Discord app
- Visit Discord Developer Portal and create an app
- Navigate to the Bot section and register a bot
- Navigate to OAuth 2 section, select bot and application.commands scopes and check bot permissions
- Copy the link and add your bot to the servers
Creating application
- Create empty directory
- Run
npm init -yoryarn init -y - Add the CommandBot package
// npm
npm install commandbot@latest
// yarn
yarn add commandbot@latest
- Create index.js file
- Import the CommandBot package
// CommonJS
const { Bot, Command } = require("commandbot");
// ES Modules (to use ESM add "type": "module" to your package.json file)
import { Bot, Command } from "commandbot";
- Initialize the bot instance
const bot = new Bot({
name: "YOUR_BOT_NAME",
prefix: "BOT_PREFIX", // bot prefix (optional) (if undefined, only slash commands will be available)
argumentSeparator: ",", // used to separate parameters from messages (optional)
clientOptions: {
intents: [..."DISCORD_API_INTENTS"],
}, // Discord.js ClientOptions (optional)
token: "DISCORD_BOT_TOKEN" // Discord bot token
applicationId: "APPLICATION_ID" // Discord application ID used to register slash commands
});
Links
- Create and add commands to the Bot instance (see Commands)
- Start your bot
bot.start(
port, // If passed, the application will create a HTTP server
true // If true, the app will register all slash commands in the Discord API (it's recommended setting it to false after registering to avoid reaching daily quota)
);