mirror of
https://github.com/DarthKilroy/Spot.git
synced 2025-12-23 20:26:49 +00:00
Update help command to use buttons & text input
also, move messages / "custom commands" to JSON file
This commit is contained in:
parent
c096deb1d0
commit
a4892d854b
18 changed files with 396 additions and 691 deletions
|
|
@ -3,6 +3,8 @@ const Discord = require('discord.js');
|
|||
const Config = require('../config.json');
|
||||
const Guild = require('./guild');
|
||||
|
||||
const customMessages = require("./messages");
|
||||
|
||||
const cachelessRequire = (path) => {
|
||||
if (typeof path === 'string') {
|
||||
delete require.cache[require.resolve(path)];
|
||||
|
|
@ -44,37 +46,32 @@ const Command = {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
parseMessage: async (message) => {
|
||||
let isCommand = false;
|
||||
if (!message.content.toLowerCase().startsWith(Config.prefix))
|
||||
return false;
|
||||
|
||||
if (message.content.toLowerCase().substr(0, Config.prefix.length) === Config.prefix) {
|
||||
let content = message.content.substr(Config.prefix.length).trim().split(' ');
|
||||
const calledCommand = content.shift().toLowerCase();
|
||||
let content = message.content.substr(Config.prefix.length).trim().split(' ');
|
||||
const calledCommand = content.shift().toLowerCase();
|
||||
|
||||
if (await Command.isValid(calledCommand, message)) {
|
||||
const member = await Guild.getMemberFromMessage(message);
|
||||
if (embed = customMessages.getEmbed(calledCommand))
|
||||
return await message.channel.send({embed});
|
||||
|
||||
if (member === null) {
|
||||
message.reply('sorry, you do not seem to be on the server.');
|
||||
} else {
|
||||
let commandName = calledCommand;
|
||||
isCommand = true;
|
||||
if (!await Command.isValid(calledCommand, message)) return;
|
||||
|
||||
const member = await Guild.getMemberFromMessage(message);
|
||||
if (member === null)
|
||||
return message.reply('sorry, you do not seem to be on the server.');
|
||||
|
||||
if (Command.commandAliases.hasOwnProperty(calledCommand)) {
|
||||
commandName = Command.commandAliases[calledCommand];
|
||||
}
|
||||
let commandName = calledCommand;
|
||||
|
||||
const commandInstance = cachelessRequire(Command.commandList.get(commandName));
|
||||
if (Command.commandAliases.hasOwnProperty(calledCommand))
|
||||
commandName = Command.commandAliases[calledCommand];
|
||||
|
||||
if (commandInstance !== null) {
|
||||
commandInstance.process(message, content, Command);
|
||||
} else {
|
||||
Command.commandList.delete(commandName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const commandInstance = cachelessRequire(Command.commandList.get(commandName));
|
||||
|
||||
return isCommand;
|
||||
if (commandInstance !== null)
|
||||
commandInstance.process(message, content, Command);
|
||||
else
|
||||
Command.commandList.delete(commandName);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue