Split up server.js and message handling
This commit is contained in:
parent
568cfcaf4c
commit
4630cefd47
1 changed files with 2 additions and 28 deletions
30
server.js
30
server.js
|
@ -16,6 +16,7 @@ client.netmodules = new Discord.Collection();
|
|||
var reloadCommands = require("./util/reloadCommands.js");
|
||||
const loadServerPrefixes = require('./util/loadServerPrefixes');
|
||||
const loadNetModules = require('./util/loadNetModules');
|
||||
const onMessage = require('./server/message');
|
||||
reloadCommands(client)
|
||||
loadNetModules(client)
|
||||
|
||||
|
@ -40,34 +41,7 @@ client.once('disconnect', () => {
|
|||
});
|
||||
|
||||
client.on('message', async message => {
|
||||
|
||||
if (client.serverPrefixes.get(message.guild.id)) {
|
||||
prefix = client.serverPrefixes.get(message.guild.id)
|
||||
} else
|
||||
prefix = globalPrefix
|
||||
|
||||
let args = message.content.slice(prefix.length).split(" ")
|
||||
|
||||
const commandName = args.shift().toLowerCase();
|
||||
const command = client.commands.get(commandName);
|
||||
const netModule = client.netmodules.get(commandName);
|
||||
if (!message.guild || message.author.bot || !message.content.startsWith(prefix)) return;
|
||||
if (!command){
|
||||
if (netModule){
|
||||
try {
|
||||
netModule.execute({message: message, args: args, client: client, prefix: prefix})
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (command.admin && owners.indexOf(message.author.id.toString()) == -1) return;
|
||||
try {
|
||||
command.execute({ message: message, args: args, client: client, prefix: prefix, owners: owners})
|
||||
} catch (error) {
|
||||
console.log(`${error}\n-------`)
|
||||
}
|
||||
onMessage(client, owners, message, globalPrefix);
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue