@voiddevs.org/slashbot
v1.1.8
Published
Create a simple empty slash bot for Discord with discord.js.
Downloads
9
Readme
@voiddevs.org/slashbot
Do you need my help? Visit our Discord server.
Node Version: 16.15.0
Installation
npm i "@voiddevs.org/slashbot" --save
# or
yarn add "@voiddevs.org/slashbot"
Usage
const { Intents } = require("discord.js");
const Client = require('@voiddevs.org/slashbot');
const $ = new Client({
token: process.env.token,
intents: [
Intents.FLAGS.GUILDS
]
});
$.client.on('ready', () => {
console.log('\n-[ Client Ready ]-')
console.log(`(!): Logged as a ${$.client.user.username}#${$.client.user.discriminator}`)
console.log(`(!): Developed with ❤️\ \ by clqu.`)
console.log(`(!): Total ${$.commands.length} commands loaded.`)
try {
$.client.user.setPresence({
activities: [
{
name: `❤️ clqu`,
type: 'PLAYING'
}
],
status: 'ONLINE'
});
} catch (err) {
console.error(err.message);
};
});
$.init();
Command Loader
// path = required, extension = required, callback = optional
$.commandLoader('./test/commands/', '.js', (cmd) => {
console.log(`(!): ${cmd} command loaded.`)
});
Custom Loader
const { fromDir } = require('@voiddevs.org/slashbot');
fromDir('./test/commands/', '.js', (files) => {
files.forEach((file) => {
const cmd = require(process.cwd()+'/'+file.split('./')[1]);
console.log(`(!): ${cmd.name} command loaded.`)
$.setCommand(cmd)
})
});
Set Command
$.setCommand({
name: "help",
description: "Help",
options: [],
run: async (client, interaction) => {
return interaction.reply('help')
}
});