Heyy! You're probably my friends! If not, then thanks for coming here! This package is fairly new, and can barely do anything! - Lightner#5294
NodeJS
>=16.6.0
You first have to install the module
npm install discord.js.ez@github:LightnerDev/discord.js.ez
Then create index.js
Then you have to require the module
const Discord = require('discord.js.ez')
Then you have to declare a new bot
const bot = new Discord.Bot({
intents: Number || 'all', //Number is used for custom intents; See: https://ziad87.net/intents/
mobile: true //Whether to show mobile status or not
})
Then you have to register a command
bot.registerCommand({
name: 'name-of-command', //no spaces allowed
async execute(message, args, bot) {
message.channel.send('a reply to the command')
}
})
Then you have to login
bot.login({
prefix: '!', //prefix to use
token: process.env.TOKEN, //token
config: {
unknownCmdMessage: 'Unknown Command!', //if the command isnt recognized but the prefix is (null for no message)
errorMessage: 'ERROR' //if the command creates error during execution (null for default; doesn't catch all errors)
}
})
Initiate the command handler with the following code
const CH = new Discord.CommandHandler('./test/Commands', bot) //replace './test/Commands' with the directory you commands are in; bot is the bot you initiated in the code
module.exports.CH = CH //Used to export the CommandHandler
In the directory above you want to make files (or sub-folders/sub-sub-folder) and put the following
module.exports = {
name: 'name-of-command', //no spaces allowed
async execute(message, args, bot) {
message.channel.send('a reply to the command')
}
}
To make a reload commands command put the following
const CH = require('./../../index.js').CH //edit `./../../index.`js` depending on the relative positions of this file and `index.js`
module.exports = {
name: 'reload',
async execute(message, args, b) {
if (message.author.id == 'YOUR_ID_HERE') {
await CH.reloadCommands()
message.react(`✅`)
} else {
message.reply('nono')
message.react(`❌`)
}
}
}
Did you know aliases are also supported?
To do them you have to put
aliases: ['alias1', 'alias2', 'alias3' ...],
in the code right after (it doesn't matter but just of simplicity)
name: 'name-of-command'
Report bugs @ https://github.com/LightnerDev/discord.js.ez/issues
Look at an example @ https://github.com/LightnerDev/discord.js.ez/tree/master/test
Thanks for reading!!! - Lightner#5294