A simple and easy to use Discord bot command handler, built for Discord.js
npm install simply-discord



A simple Discord bot command handler that is easy to use, built for Discord.js
``js
const { client } = new SimplyDiscord({
defaultPrefix: '-',
commandsDir: './commands',
eventsDir: './events',
allowDMs: false
})
.setGuildPrefix('GUILD_ID', 'NEW_PREFIX')
.setCommandsDir('NEW_DIRECTORY')
.setEventsDir('NEW_DIRECTORY')
.setDefaultPrefix('NEW_DEFAULT_PREFIX')
.toggleDMs()
.reload();
`
Params:
| Param | Type | Info
| ------------- | :---: | ------------- |
| client | Discord.Client | The Discord client, if not passed one will be createdobject
| options | | More info below
Available Options:
| Option | Type | Default | Info |
| ------------- | :---: | :---: | ------------- |
| options | object | undefined | Options to configure the handlerstring
| options.defaultPrefix | | ! | Default prefix to use in-case of no guild prefixstring
| options.commandsDir | | ./commands | Folder containing all your commandsstring
| options.eventsDir | | ./events | Folder containing your event filesboolean
| options.allowDMs | | true | Bot should respond in DMs?
`js
// Example Functions
const Handler = new SimplyDiscord();
// Set the guild prefix
Handler.setGuildPrefix('714478443099873310', '-');
// Set the dir but do not reload commands
Handler.setCommandsDir('./commands/sub', false);
// Set the events dir
// By default it will reload commands/events
Handler.setEventsDir('./events/new');
// Manually reload commands/events (Default will reload both)
Handler.reload('commands'); // Reload just commands
Handler.reload('events'); // Reload just events
Handler.reload(); // Reload both
// Toggle DMs (Specify true/false or it will flip the current state)
console.log(Handler.allowDMs) // Output -> True
Handler.toggleDMs();
console.log(Handler.allowDMs) // Output -> False
`
| Function | Params | Info |
| ------------- | :---: | ------------- |
| setCommandsDir | ('Directory') | Update the folder where your commands are located |('Prefix')
| setDefaultPrefix | | Update the default prefix |('GuildID', 'Prefix')
| setGuildPrefix | | Set the guild prefix to the client.prefixes collection |('Directory')
| setEventsDir | | Update the folder where your events are located |(true/false)
| toggleDMs | | Toggle if DMs should be allowed, sending nothing with switch it |('commands'/'events')
| reload | | Reload commands/events or both |
Using the handler:
`js
const Discord = require('discord.js');
const SimplyDiscord = require('simply-discord');
const client = new Discord.Client();
new SimplyDiscord(client, {
commandsDir: 'lib/commands'
});
``
Note: Simply Discord will create a client for you if you don't provide onejs
const SimplyDiscord = require('simply-discord');
/ Client is a property of the SimplyDiscord Class, use this to access the Discord Client /
const { client } = new SimplyDiscord({ commandsDir: 'lib/commands' });
/ Assign it to a variable and use that to access the props and functions /
const simply = new SimplyDiscord({ commandsDir: 'lib/commands' });
const client = simply.client;
/ Minimum usage /
const simply = new SimplyDiscord();
`
`js`
module.exports = {
name: 'ping',
aliases: ['p'],
category: 'Utils',
cooldown: 10, / In seconds, this example is 10 seconds /
async run ({ client, handler, message, args }) {
// Your command code ...
}
};
`js``
module.exports = {
name: 'ready',
once: true,
async run (client, handler, EVENT_PARAMS) {
/*
EVENT_PARAMS are any params from the event itself,
check the Discord.js Docs for more info.
*/
}
};
Future Ideas
Look into finding a better way to handle the guild checking.