Bot
extends Client
Creates a bot client.
Import
import { Bot } from 'discordkit';
Constructor
Properties
The bot's command collection.
Type: Collection<string, Command>
Returns true if slash commands are loaded.
Type: boolean
@discord.js/rest
Type: REST
Methods
This function is executed if the command does not have the .noPerm() function.
Returns: Promise<any> | any
Adds commands to the bot.
Returns: void
Example
const client = new Bot({ ... });
const ping = new Command({ ... });
const ban = new Command({ ... });
client.addCommand([ ping, ban ]);
Adds events to the bot.
Returns: void
Example
const client = new Bot({ ... });
const onReady = new Event({ ... });
const onMessageCreate = new Event({ ... });
client.addEvent([ onReady, onMessageCreate ]);
Sends commands to Discord.
Returns: Promise<void>
Example
const client = new Bot({ ... });
client.init('super-secret-token');
client.on('commandsLoad', async () => {
const newCmd = new Command({ ... });
client.addCommand(newCmd)
await client.loadCommands();
console.log('New command added.');
});
Sets the default no authorization message.
Returns: void
Example
const client = new Bot({ ... });
client.setDefaultNoPerm(async (bot, interaction) => {
await interaction.reply({
content: 'not authorized'
});
});
It starts the bot and loads the commands.
Returns: void
Example
import { Bot, Intents } from 'discordkit';
const client = new Bot({
intents: [
Intents.Guilds
]
});
client.init('super-secret-token');
Events
It is triggered when commands are loaded after the bot is started.