discord-structures
v1.0.6
Published
the basic structures for any discord bot.
Downloads
3
Maintainers
Readme
structures
This npm module is here because i am tired of making them
how to use:
Setup
in your package.json run npm install
Example Command:
let { CommandStructure } = require('discord-structures')
class Ping extends CommandStructure {
constructor() {
super();
this.name = 'ping' // can be used in super as well
this.aliases = [' pong ']
}
async execute({ message }) or (message) {
return await message.channel.send('Pong!'); // Discord.js
return await message.channel.createMessage('Pong!'); // Eris
}
}
module.exports = Ping;
// or
module.exports = new Ping();
The Structure Client
very simple to set up
all the structure has is a help command. more features will be coming soon
Doc:
| Name | Type | |-------------|-------------| | message | Object | | client | Object | | lib | String | | prefix | String | | disableHelp | Boolean | | commands | Object |
example:
let { StructureClient } = require('discord-structures');
new StructureClient(message, client, 'eris', '!', false) // true is only if you want to disable the help command
The client is supposed to be like this
let { Client } = require('eris'); // you can also go with discord.js but the lib has to be djs
let { token } = require('./config.json');
let { StructureClient } = require('structures');
let client = new Client(token);
client.once('ready', () => {
console.log('Ready');
});
let command = require('./test');
client.commands = new Map();
client.commands.set(command.name, command)
client.on('messageCreate', async (message) => {
new StructureClient(message, client, 'eris', '!', false);
if (message.content === `!${command.name}` || message.content === `!${command.aliases}`) {
command.execute({ message });
}
})
client.connect();
The command object can also be:
if there is no json object, the help menu will show undefined
{
"name": ["your commands here"]
}