discordful-commander
v1.0.2
Published
Commander is a command module for discordful
Downloads
1
Readme
Discordful-Commander
Commander is a command module for discordful
How to use
Commander is fairly easy to use, my goal was to make it simple without leaving anything advanced out.
To start with Commander you need to create a new Commander instance
var Commander = require('discordful-commander');
var cmder = new Commander({
prefix: '/',
selfbot: false
})
You can give the Commander constructor a few options, some of the important ones are prefix
and selfbot
.
selfbot
makes it so the parser doesnt respond to other users but the connected user itself.prefix
is the prefix of the bot to activate commands.
To create a new commander simple call cmder.command
cmder
.command('ping', { // Register new a command
desc: 'Pings the bot' // Description of the command
})
.callback(function(msg, arg1, arg2, arg3) { // This adds a callback to the command when its activated
// First argument is the message object generated by Commander itself.
// This has a few neat properties such as msg.date which is parsed by chrono
// the arguments are special objects, you can get their values with arg.value
// to get more information on these check out src/MessageInterfaces/...
this.reply('Pong!') // The enviroment allows you to call reply or send to send a message
});
bot.event('MESSAGE_CREATE') // Create an event pipeline with discordful
.use(cmder.parse()) // Add the parser to the event pipeline
.use(function(success, message) { // Next in line gives a success parameter if there was a command activated
if (success) console.log(`${message.author.username}#${message.author.discriminator} - ${message.resolveContent()}`);
});
More documentation will come later