This repository has been archived by the owner on Aug 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURES] Destruction of App.js (#137)
* The Destruction of App.js * [PR] Changelog && Patch Bump * [PR] Eslint && Array-prefixing fix
- Loading branch information
1 parent
5eb988b
commit eb041f3
Showing
8 changed files
with
87 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = async (client, msg, command, args = undefined) => { | ||
const validCommand = this.getCommand(client, command); | ||
if (!validCommand) return; | ||
const response = this.runInhibitors(client, msg, validCommand); | ||
if (response) return msg.reply(response); | ||
try { | ||
const params = await client.funcs.usage.run(client, msg, validCommand, args); | ||
validCommand.run(client, msg, params); | ||
} catch (error) { | ||
if (error) { | ||
if (error.code === 1 && client.config.cmdPrompt) { | ||
client.funcs.awaitMessage(client, msg, validCommand, [], error.message); | ||
} else { | ||
if (error.stack) client.emit("error", error.stack); | ||
msg.channel.sendCode("JSON", (error.message || error)).catch(err => client.emit("error", err)); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
exports.getCommand = (client, command) => { | ||
if (client.commands.has(command)) { | ||
return client.commands.get(command); | ||
} else if (client.aliases.has(command)) { | ||
return client.commands.get(client.aliases.get(command)); | ||
} | ||
return false; | ||
}; | ||
|
||
exports.runInhibitors = (client, msg, command) => { | ||
const priority = client.commandInhibitors.array().sort((low, high) => low.conf.priority < high.conf.priority); | ||
let response; | ||
priority.some((inhibitor) => { // eslint-disable-line | ||
if (inhibitor.conf.enabled) { | ||
response = inhibitor.run(client, msg, command); | ||
if (response) return true; | ||
} | ||
}); | ||
return response; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = (client, msg, edited = false) => { | ||
if (client.config.ignoreBots && msg.author.bot) return false; // Ignore Bots if True | ||
if (client.config.ignoreSelf && msg.author.id === client.user.id) return false; // Ignore Self if true | ||
if (client.config.selfbot && msg.author.id !== client.user.id) return false; // Ignore other users if selfbot is true | ||
if (!client.config.selfbot && msg.author.id === client.user.id) return false; // Ignore other users if selfbot but config option is false | ||
if (!client.config.editableCommands && edited) return false; // Ignore message if owner doesn't allow editableCommands | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = (client, msg, usage = false) => { | ||
const prefix = this.getPrefix(client, msg); | ||
if (!prefix) return; | ||
const prefixLength = this.getLength(client, msg, prefix); | ||
if (usage) return prefixLength; | ||
return msg.content.slice(prefixLength).split(" ")[0].toLowerCase(); | ||
}; | ||
|
||
exports.getLength = (client, msg, prefix) => { | ||
if (client.config.prefixMention === prefix) { | ||
return prefix.exec(msg.content)[0].length + 1; | ||
} | ||
return prefix.exec(msg.content)[0].length; | ||
}; | ||
|
||
exports.getPrefix = (client, msg) => { | ||
if (client.config.prefixMention.test(msg.content)) { | ||
return client.config.prefixMention; | ||
} | ||
const prefix = msg.guildConf.prefix; | ||
if (prefix instanceof Array) { | ||
prefix.forEach((prefix) => { | ||
if (msg.content.startsWith(prefix)) prefix = RegExp(`^${prefix}`); | ||
else prefix = false; | ||
}); | ||
return prefix; | ||
} | ||
if (msg.content.startsWith(prefix)) return new RegExp(`^${prefix}`); // eslint-disable-line | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters