new stuff
This commit is contained in:
commit
a5b6425af1
22 changed files with 1375 additions and 0 deletions
9
bot/events/error.js
Normal file
9
bot/events/error.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = class {
|
||||
constructor (client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async run (error) {
|
||||
this.client.logger.log(`An error event was sent by Discord.js: \n${JSON.stringify(error)}`, "error");
|
||||
}
|
||||
};
|
46
bot/events/message.js
Normal file
46
bot/events/message.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
// The MESSAGE event runs anytime a message is received
|
||||
// Note that due to the binding of client to every event, every event
|
||||
// goes `client, other, args` when this function is run.
|
||||
|
||||
module.exports = class {
|
||||
constructor (client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async run (message) {
|
||||
if (message.author.bot) return;
|
||||
|
||||
let data = new Object();
|
||||
|
||||
if (message.content.indexOf(this.client.config.defaultPrefix) !== 0) return;
|
||||
|
||||
const args = message.content.slice(this.client.config.defaultPrefix.length).trim().split(/ +/g);
|
||||
const command = args.shift().toLowerCase();
|
||||
|
||||
// Cache uncached members
|
||||
if (message.guild && !message.member) await message.guild.fetchMember(message.author);
|
||||
|
||||
const cmd = this.client.commands.get(command) || this.client.commands.get(this.client.aliases.get(command));
|
||||
if (!cmd) return;
|
||||
|
||||
if (cmd && cmd.conf.devOnly && this.client.util.isDeveloper(message.author.id) !== true) {
|
||||
return message.channel.send("devs only!");
|
||||
}
|
||||
if (cmd && !message.guild && cmd.conf.guildOnly) {
|
||||
return message.channel.send("This command is unavailable via private message. Please run this command in a guild.");
|
||||
}
|
||||
|
||||
|
||||
message.flags = [];
|
||||
while (args[0] &&args[0][0] === "-") {
|
||||
message.flags.push(args.shift().slice(1));
|
||||
}
|
||||
|
||||
message.util = this.client.messageUtil;
|
||||
|
||||
cmd.run(message, args, data);
|
||||
this.client.logger.cmd(`Command ran: ${message.content}`);
|
||||
|
||||
// TODO: Command caching if it"s worth it
|
||||
}
|
||||
};
|
10
bot/events/ready.js
Normal file
10
bot/events/ready.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
module.exports = class {
|
||||
constructor (client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async run () {
|
||||
await this.client.wait(1000);
|
||||
this.client.logger.ready(`Connected to Discord as ${this.client.user.tag}`);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue