Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Commit

Permalink
0.18.1 UtilitiesHotfix (#154)
Browse files Browse the repository at this point in the history
* Bugfix: prefixMention undefined

When the ready event takes too long and a message event triggers before it executes, an error crashed the bot. This is now resolved (but prefix mentions are ignored until it's available)

* Event Logging (warn, error, disconnect)

Added logging for warn, error, and disconnect events emitted by discord.js

* msg.member.permLevel

Added permission level to msg.member so commands can do sub-checks (for example, a command with various actions with different permission levels)

* chore(package): update dependencies (#105)

https://greenkeeper.io/

* [BUGFIX] Fix function inits (#106)

* [BUG-FIX] Move Function init() to ready
SEMVER: PATCH

Why:

* Some function inits require cache to work properly

This change addresses the need by:

*  If a function's init() required something from a client collection, it failed to execute properly.
*  Moving init() functions the ready event seems like an appropriate workaround for now.

Fixes #106

* [PR] Bump Package.json
SEMVER:

Why:

* Package.json is being bumped by a semver patch increment

* Remove stupid comment

This damn "guild removed but not found" message has been plaguing me since I added confs.

* [FEATURE] New Configuration System (#107)

* [BUGFIX] Many Fixes/Additions (#108)

* Fixed Conf.js to use new Configuration System

* Changelog updated

* Events Added For Configuration System

* Clean function now properly removes client.user.email

* [FEATURE] Configuration Update (#110)

* Broke down Configuration into smaller, manageable parts.

* Changelog && Patch Bump

* [FEATURE] New Argument Prompting System (#111)

* New Argument Prompting System

* [PR] Changelog && Patch Bump

* [PR] Actual Patch Bump

* [PR] loadCommands fix

* [PR] Changelog - loadCommands

* [PR] Fix for My Idiotic Mistake

* [PR] Fix for My Idiotic Mistake

* [PR] Configuration Client Option to Disable Prompts

* [PR] Abort is now case-insensitive

* [PR] Fix for DMs

* [PR] Changelog for DMs

* [PR] Translation Fixed for DMs

* [PR] Config.prefix now accepts a String or an Array of Strings

* [PR] Reload.js Bugfix && Changelog Update

* [PR] Prefix.length error fixed

* [BUGFIX] Fixed Selfbot Prefix Mentioning Crashing with CMD Prompts (#112)

* Fixed Selfbot Prefix Mentioning Crashing with CMD Prompts

* [PR] Changelog

* Motiond3v/helpdm (#114)

* Help command is now a Direct Message

* Help command is now a Direct Message

* Update help.js

* Update package.json

* Fixed Bugs and Patch Bumped (#113)

* Fixed Bugs and Patch Bumped

* Update package.json

* Fixed selfbot's not being able to DM themselves (#115)

[BUG-FIX] Fixed selfbot's not being able to DM themselves

* [BUGFIXES] Bugfixes (#116)

* Bugfix && Changelog

* [PR] Reload.js Bug Fix

* [PR] Changelog

* [PR] Reload Clarification/Fix

* [PR] Patch Bump

* [PR] Cyber is a bish

* [NODE] Async/Await all the things (#117)

* Async/Await all the things

* Re-enabled disconnect event

* [PR] Fixed all commands that didnt have a usage

* [PR] New Initialize Function

* [PR] Fixed Wrong Shorthands

* [PR] Added Initialize Function to Changelog

* [BUG-FIX] More bug fixes (#118)

* Selfbot BugFixes

* [PR] New Download Command Linked to Pieces

* [PR] Changelog && Patch Bump

* [PR] Evies Changes

* [PR] Fixed spelling error

* [PR] Client.destroy() removed permanently.

* [PR] Changelog

* [PR] Features && Bug Fixes

* [PR] Help Command Fix

* [PR] Disable Typo Fixed

* [PR] Download Fix

* Download.js Fix (#120)

* Indev (#121)

* Download.js Fix

* Fixes

* No longer failed

* [BUGFIXES] More Bugfixes (#122)

* Bunch of Bugfixes

* [PR] Bunch of Command/inhibitor fixes

* ESLint お願いします

* [PR] Provider Requires

* [BUG-FIX] User Count now correctly displays. (#123)

SEMVER: Patch

Why:

* Allows Komada installations that do not fetchAllMembers to be able to
have an accurate user count..

* [BUG-FIX] Help Command is fixed
SEMVER: Patch

Why:

* A Fix to bring the Help Command back into working order

This change addresses the need by:

* Changing the buildHelp code from `msg.author.permlvl` to
`msg.member.permlvl`

* Removal of console.log(params)

* [BUG-FIX] Prompts & Help (#124)

* Prompts Fix

* [PR] Msg.member.permLevel -> msg.author.permLevel

* [PR] Changelog for Prompts

* More AwaitMessage/Prompt Fixes

* [PR] Priority Fix for Inhibs

* [PR] Cmd.Rejected

* [PR] Fix for cmd.Rejected

* [PR] .some() Change

* [PR] Eslint Disable

* [BUG-FIX] Lotsa Bugs (#125)

* Prompts Fix

* [PR] Msg.member.permLevel -> msg.author.permLevel

* [PR] Changelog for Prompts

* More AwaitMessage/Prompt Fixes

* [PR] Priority Fix for Inhibs

* [PR] Cmd.Rejected

* [PR] Fix for cmd.Rejected

* [PR] .some() Change

* [PR] Eslint Disable

* Events Crucial Fix

* [PR] Fixed Event Loading (#126)

* [PR] Fixed Event Loading

* Update CHANGELOG.md

* Update package.json

* You've encountered a wild Buggerfree! (#127)

* You encountered a lone Buggerfree.

* You saw nothing Faith

* [BUG-FIX] Fixes Dep Installation on Client Functions
SEMVER: N/A

* Extended help (#128)

* Extended Help added

* [PR] Inhibitors changed to await

* [PR] Usage Spell checking

* [PR] Bump && Changelog

* Potential Inhib fix (#129)

* Inhibitor Fix (#130)

* Inhibitor Fix

* Removed useless async

* [PR] Help Fix

* [Feature] New Command &  Inhibitor (#131)

* [FEATURE] Transfer Command Added
SEMVER: N/A

Why:

* A transfer command that copies "pieces" from Core directories to
client directories has been added.

* [FEATURE] Added runIn Inhibitor
SEMVER:
Minor
Why:

* This now allows a better variety in how/where commands can be run

This change addresses the need by:

* changing the boolean-based guildOnly property
to an array of channel types

* Sounds better

* Removal of Async/Await... not working properly (#132)

* [FEATURE] New error handling && Command Handler (#133)

* New Errors && Command Handlers.. and other stuff

* [PR] Minor Bump && Changelog

* [PR] Changelog && uncaughtPromise fix

* [PR] Fix for Client being undefined

* [PR] Update README

* Holy fuck Depth: 5 are you kidding me?

* [BUGFIX] Fixes dem nasty Empty Message errors.

* [BUGFIX] Refer to previous commit

Refer to #347

* [BUGFIX] Refer to #347

Refer to #347

* [BUGFIX] Error fixing (#134)

* Fix for Cmd Prompts && Revert of Log.js

* [PR] Changelog && Patch Bump

* Features (#135)

* One Super Big Commit

* [PR] Eslinting

* [PR] Jsdocing of Config Types && Config.js

* [PR] More jsdocing

* [BUGFIXES] Merge Indev (#136)

* Bugfixes, Whoopsies

* Changelog Updated

* [FEATURES] Destruction of App.js (#137)

* The Destruction of App.js

* [PR] Changelog && Patch Bump

* [PR] Eslint && Array-prefixing fix

* [BUGFIXES] Reload && Events (#139)

* Bugfixes && Changes

* [PR] Patch Bump

* Revert "[BUGFIXES] Reload && Events" (#140)

* [BUG FIXES] Reload && Events && Inits (#141)

* Bugfixes && Changes

* [PR] Patch Bump

* Continuation of #141

* Continuation of #141 Part 2

* [BUGFIX] Initialisation is now fixed.

* [BUG-FIX] Booleans are now properly validated

* Fixed some typos in parseUsage (#142)

* Fixed some typos

* Update parseUsage.js

* CHANGELOG

* Bump to 0.18.0

* [BUGFIX/Feature] Fixed Event Loading && Added Internal Utils (#143)

* Moved loading to Utils

* Time for more utils

* FML

* Faith fixed the regex

* Typo out of 10

* regexp

* Fixed Configs

* ESlint

* temp

* ^^^^

* typo

* We are not using initialize function again

* Client.ready

* Added Env Var support for clientDir

* Removal of client.email from clean function

* ESlint + Updating of ~Info Command

* ...

* Fix a typo on line 70 (#144)

[FIX] Fix a typo on line 70

* reload all commands

* whoops

* Silent inhibitors (#146)

* Added silent inhibitors

If you have an inhibitor and you set `return true;`, it'll stop execution instead of sending an error. However, you are still able to do `return "This is a string"`, and it'll reply with the inserted string.

* Added Silent Inhibitors

* Update handleCommand.js

* Update package.json

* Fixed

* Added the new Discord.js methods. (#147)

* Update package.json

* Update CHANGELOG.md

* Added new Discord.js utils

* Update .travis.yml

* Sentry integration

* Update app.js

* grrr

* Is this it?

* ESLint

* Update package.json

* Update CHANGELOG.md

* Update package.json

* Fixed reload events

* Update CHANGELOG.md

* Fixed `'file' is not defined`

* ESLint

* Update package.json

* Update app.js

* Update package.json

* Update CHANGELOG.md

* ESLint

* Fixed codeblocks and missing information (no error stack)

* Fixed missing codeblocks

* Update CHANGELOG.md

* Add error.stack to case warn.

* Disconnect event should print "Disconnected" now

* Update CHANGELOG.md

* Update app.js

* util.inspect error, warn, and better disconnect message.

* Update CHANGELOG.md

* Update app.js

* Oops
  • Loading branch information
CyberiumShadow authored Mar 17, 2017
1 parent b0c7907 commit 1c0f067
Show file tree
Hide file tree
Showing 24 changed files with 416 additions and 65 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json → .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"no-shadow": "warn",
"no-plusplus": "off",
"radix": ["error", "as-needed"],
"max-len": "warn",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"import/no-dynamic-require": "warn",
Expand Down
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
language: node_js
node_js:
- "6"
- "7"
install: npm install
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/0926b82fc22ea0760ede
on_success: always # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
107 changes: 106 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,110 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [0.18.1] - 2017-03-17
### Added
- Sentry Integration for Error Tracking purposes direct to Komada Devs,
- Added the new utils from `Discord.js#master`: escapeMarkdown and splitMessage are now in `client.methods`.
- Added support for silent inhibitors (if `return true`, it won't send a reply).
- Added Environmental Variable support for clientDir.
- Added regExpEscape function.

### Changed
- Add error.stack to the function log.js to avoid [object Object].
- Disconnect event should now prints a more human readable error instead of `[object Object]`.
- error and warn event errors are now inspected with depth 0, for better debug.
- loading Functions are removed from Functions folder and moved to a Utils folder. (This folder will be there for future features as well.)

### Fixed
- Reloading pieces should now return the error stack in a codeblock.
- Fixed function reload event.
- Fixed command reload all. underlying bug since 0.15.x days.
- Fixed typo in validateData function
- Fixed Default Conf initialize. (No longer outputs undefined)
- Fixed invalid regex for prefixes in parseCommand

### Removed
- client.email redaction from the clean function.

## [0.18.0] - 2017-03-16
### Added
- Added a bunch of unusable configuration options that'll make their debut soon.
- All Bad Requests/Forbiddens.. etc, now properly give a human readable error in console or chat, depending on the error. (Not as of (0.17.0).. must be fixed) ***
- New Error Creator
- New CommandHandler (Removed it from message event)
- New Core Command "Transfer"
- New extended help feature added.
- New Beta Configuration (Needs heavy testing)
- New Argument Prompting for Commands
- ~~New Initialize Function to alleviate undefined errors~~ Reverted in #139
- New Download Command

### Changed
- ~~All pieces now initialize upon being loaded, in order.~~ ~~Reverted in 0.17.3~~ Reimplemented in 0.17.4 within `client.on("ready")`
- Changed Emojis to unicode variants in Reload.js
- Broke down App.js Message Event into several smaller, changeable parts.
- newError changed to send arguments to awaitMessage when errors are from usage
- awaitMessage changed to work perfectly with the new system
- msg.author.permLevel is now available immediately on a message, instead of after inhibitors run correctly.
- Usage Inhibitor is now a function instead, which will help issues with racing and prompts.
- All Inhibitors now return values instead of using promises to resolve or reject. (Change will be reflected on Documentation soon)
- Reverted Log function for the time being.
- Many Files to use the new Error creator
- guildOnly Inhibitor is now a `runIn` Inhibitor.
- Inhibitors now use .some() to determine if more inhibitors should be ran.
- Stats command now uses `<Collection>.reduce` to correctly determine User Count when fetchAllMembers is false
- Changed info to no longer mention Evie because she said she was tired of it.. kek
- New runCommandInhibitors should be much faster and prioritizes inhibitors via a prioritiy configuration setting.
- Old Configuration system now points to the new configuration system, to ease the trouble of updating to newer versions of Komada
- Pieces now have specific order they load in. (Functions, Providers, Commands, Inhibitors, Monitors, Events)
- Confs.js uses new configuration system now
- Configuration now split into smaller parts as requested.
- Help command is now a Direct Message.
- Async/Await for all pieces && app.js
- dataProviders renamed to Providers

### Fixed
- Fixed validateData Booleans.
- Fixed Reloading Events not loading new events correctly.
- Fixed Typo in transfer command
- Fixed Usage not working properly with selective
- permissionLevels -> permissionLevel
- Unchanged Package.json links to the repository
- App.js uncaughtWarnings reverted (for now)
- Download.js Fix && Reload.js typo fix.
- Inhibitors now run one by one until one of them fails or all succeed. Fixes race conditions permanently.
- Empty Message errors
- CmdPrompts should now be fixed completely (as of 0.17.0)
- Inhibitors now await
- Usage typos fixed
- LoadFunctions now calls itself when installing a new dependency in a client function
- Fixed Default configuration not being read before guild configurations are created
- Inhibitors now are correctly 'disabled' when set to be.
- Events.... now should be fixed
- Inhibitors now running in the correct order
- Fixed Prompts sending an extra message.
- Help command back to msg.author...
- Help command is now working. `msg.author.permlvl => msg.member.permlvl`.
- Bunch of fixes for Inhibitors/Commands
- Fixed Typo in disable
- Fixed Help Command sending extra message when DMed
- New Configuration system fixed and outputs files correctly now.
- No longer able to kill komada with Client.destroy()
- All Pieces should now initialize in the correct order.
- loadCommands no longer counts/loads "Ghost" commands.
- DMs throwing errors with new Config System && permLevel
- Fixed Reload not erroring on new commands that aren't found
- Fixed Bug on Selfbot mentions introduced with the new Argument Prompts
- Fixed Bug on Help not showing all commands with new Argument System
- Fixed another bug introduced with the new Argument System where Permissions weren't finalized before Prompts
- Fixed Bug within reload.js that prevented new commands from being loaded
- More Selfbot Bugs Fixed
- More Reload function fixes for commands

### Removed
- Old initialize system (Was borked)
- Old Configuration System
- Selfbot Inhibitor

## [0.18.0] - 2017-03-16
### Added
Expand Down Expand Up @@ -178,12 +282,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Various Confs fixes from [UnseenFaith]
- Usage Addition/ParseUsage fix from [UnseenFaith]

[Unreleased]: https://github.com/eslachance/komada/compare/0.18.0...indev
[Unreleased]: https://github.com/eslachance/komada/compare/0.18.1...indev
[0.10.0]: https://github.com/eslachance/komada/compare/1627e6deb1d8c352d83e52ccd590f2330f5f8bb2...0.10.0
[0.11.0]: https://github.com/eslachance/komada/compare/0.10.0...0.11.0
[0.12.0]: https://github.com/eslachance/komada/compare/0.11.0...0.12.0
[0.12.4]: https://github.com/eslachance/komada/compare/0.12.0...0.12.4
[0.18.0]: https://github.com/eslachance/komada/compare/0.12.4...0.18
[0.18.1]: https://github.com/eslachance/komada/compare/0.12.4...0.18.1

[vzwGrey]: https://github.com/vzwGrey
[eslachance]: https://github.com/eslachance
Expand Down
37 changes: 24 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const Discord = require("discord.js");
const path = require("path");
const util = require("util");

const loadFunctions = require("./utils/loadFunctions.js");
const loadEvents = require("./utils/loadEvents.js");
const loadProviders = require("./utils/loadProviders.js");
const loadCommands = require("./utils/loadCommands.js");
const loadCommandInhibitors = require("./utils/loadCommandInhibitors.js");
const loadMessageMonitors = require("./utils/loadMessageMonitors.js");

const loadFunctions = require("./functions/loadFunctions.js");
const Config = require("./classes/Config.js");

exports.start = async (config) => {
Expand All @@ -19,37 +26,42 @@ exports.start = async (config) => {
client.messageMonitors = new Discord.Collection();
client.providers = new Discord.Collection();

// Extend Client with Native Discord.js Functions for use in our pieces.
// Extend Client with Native Discord.js Functions for use in our pieces.
client.methods = {};
client.methods.Collection = Discord.Collection;
client.methods.Embed = Discord.RichEmbed;
client.methods.MessageCollector = Discord.MessageCollector;
client.methods.Webhook = Discord.WebhookClient;
client.methods.escapeMarkdown = Discord.escapeMarkdown;
client.methods.splitMessage = Discord.splitMessage;

client.coreBaseDir = `${__dirname}${path.sep}`;
client.clientBaseDir = `${process.cwd()}${path.sep}`;
client.clientBaseDir = `${process.env.clientDir || process.cwd()}${path.sep}`;
client.guildConfs = Config.guildConfs;
client.configuration = Config;

await loadEvents(client);

client.once("ready", async () => {
client.config.prefixMention = new RegExp(`^<@!?${client.user.id}>`);
client.configuration.initialize(client);
await client.configuration.initialize(client);
await loadFunctions(client);
await client.funcs.loadProviders(client);
await client.funcs.loadCommands(client);
await client.funcs.loadCommandInhibitors(client);
await client.funcs.loadMessageMonitors(client);
await client.funcs.loadEvents(client);
await loadProviders(client);
await loadCommands(client);
await loadCommandInhibitors(client);
await loadMessageMonitors(client);
client.i18n = client.funcs.loadLocalizations;
client.i18n.init(client);
client.destroy = () => "You cannot use this within Komada, use process.exit() instead.";
client.ready = true;
});

client.on("error", e => client.funcs.log(e, "error"));
client.on("warn", w => client.funcs.log(w, "warning"));
client.on("disconnect", e => client.funcs.log(e, "error"));
client.on("error", e => client.funcs.log(util.inspect(e, { depth: 0 }), "error"));
client.on("warn", w => client.funcs.log(util.inspect(w, { depth: 0 }), "warn"));
client.on("disconnect", e => client.funcs.log(`Disconnected | ${e.code}: ${e.reason}`, "error"));

client.on("message", async (msg) => {
if (!client.ready) return;
await client.funcs.runMessageMonitors(client, msg);
msg.author.permLevel = await client.funcs.permissionLevel(client, msg.author, msg.guild);
msg.guildConf = Config.get(msg.guild);
Expand All @@ -62,7 +74,6 @@ exports.start = async (config) => {
client.login(client.config.botToken);
return client;
};

process.on("unhandledRejection", (err) => {
if (!err) return;
console.error(`Uncaught Promise Error: \n${err.stack || err}`);
Expand Down
2 changes: 1 addition & 1 deletion classes/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Config {
.then((conf) => {
if (conf) defaultConf = conf;
})
.catch(() => fs.outputJSONAsync(`${dataDir}${path.sep}${defaultFile}`));
.catch(() => fs.outputJSONAsync(`${dataDir}${path.sep}${defaultFile}`, defaultConf));
client.guilds.forEach((guild) => {
fs.readJSONAsync(path.resolve(`${dataDir}${path.sep}${guild.id}.json`))
.then((thisConf) => {
Expand Down
2 changes: 1 addition & 1 deletion commands/System/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports.run = (client, msg, [link, piece, folder = "Downloaded"]) => {
if (client.messageMonitors.has(name)) return msg.channel.sendMessage(`<@!${msg.author.id}> | That message monitor already exists in your bot. Aborting the load.`);
break;
case "providers":
if (client.providers.has(name)) return msg.channel.sendMessage(`<@!${msg.author.id} | That provider already exists in your bot. Aborting the load.`);
if (client.providers.has(name)) return msg.channel.sendMessage(`<@!${msg.author.id}> | That provider already exists in your bot. Aborting the load.`);
break;
default:
return "This will never trigger";
Expand Down
18 changes: 17 additions & 1 deletion commands/System/info.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
exports.run = (client, msg) => {
msg.channel.sendMessage("This bot is built on the Komada framework, a plug-and-play bot builder made by Dirigeant's team of dedicated developers. For more information visit: <https://komada.js.org>");
const information = `
Komada is a 'plug-and-play' framework built on top of the Discord.js library.
Most of the code is modularized, which allows developers to edit Komada to suit their needs.
Some features of Komada include:
• Fast Loading times with ES7 Support (Async/Await)
• Per-server settings for each guild, that can be extended with your own code
• Customizable Command system with automated usage parsing and easy to use reloading and downloading modules
• "Monitors" which can watch messages and act on them, like a normal message event (Swear Filters, Spam Protection, etc)
• "Inhibitors" which can prevent commands from running based on a set of parameters (Permissions, Blacklists, etc)
• "Providers" which allow you to connect with an outside database of your choosing **soon**:tm:
• Internal "Functions" which allow you to use functions anywhere where you have access to a client variable.
We hope to be a 100% customizable framework that can cater to all audiences. We do frequent updates and bugfixes when available.
If you're interested in us, check us out at https://komada.js.org
`;
msg.channel.send(information);
};

exports.conf = {
Expand Down
2 changes: 1 addition & 1 deletion commands/System/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports.run = async (client, msg, [type, name]) => {
case "command":
switch (name) {
case "all":
await client.funcs.loadCommands(client);
await require(`${client.coreBaseDir}utils/loadCommands.js`)(client);
msg.channel.sendMessage("✅ Reloaded all commands.");
break;
default:
Expand Down
1 change: 0 additions & 1 deletion functions/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ function sensitivePattern(client) {
let pattern = "";
if (client.token) pattern += client.token;
if (client.token) pattern += (pattern.length > 0 ? "|" : "") + client.token;
if (client.email) pattern += (pattern.length > 0 ? "|" : "") + client.email;
if (client.user.email) pattern += (pattern.length > 0 ? "|" : "") + client.user.email;
if (client.password) pattern += (pattern.length > 0 ? "|" : "") + client.password;
this.sensitivePattern = new RegExp(pattern, "gi");
Expand Down
5 changes: 4 additions & 1 deletion functions/handleCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ 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);
if (response) {
if (typeof response === "string") return msg.reply(response);
return;
}
try {
const params = await client.funcs.usage.run(client, msg, validCommand, args);
validCommand.run(client, msg, params);
Expand Down
2 changes: 1 addition & 1 deletion functions/handleMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports = (client, msg, edited = false) => {
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;
}
};
5 changes: 3 additions & 2 deletions functions/loadSingleCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi
cmd.init(client);
}
} catch (e) {
reject(`Could not load existing command data: ${e.stack}`);
reject(`Could not load existing command data: \`\`\`js\n${e.stack}\`\`\``);
}
} else {
try {
cmd = require(loadPath);
if (cmd.conf.selfbot && !client.config.selfbot) {
return reject(`The command \`${cmd.help.name}\` is only usable in selfbots!`);
}
delete require.cache[require.resolve(loadPath)];
if (cmd.init) cmd.init(client);
let pathParts = loadPath.split(path.sep);
pathParts = pathParts.slice(pathParts.indexOf("commands") + 1);
Expand All @@ -46,7 +47,7 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi
});
client.funcs.loadSingleCommand(client, command, false, loadPath);
} else {
reject(`Could not load new command data: ${e.stack}`);
reject(`Could not load new command data: \`\`\`js\n${e.stack}\`\`\``);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion functions/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = (data, type = "log") => {
console.warn(`${clk.black.bgYellow(`[${moment().format("YYYY-MM-DD HH:mm:ss")}]`)} ${data}`);
break;
case "error":
console.error(`${clk.bgRed(`[${moment().format("YYYY-MM-DD HH:mm:ss")}]`)} ${data}`);
console.error(`${clk.bgRed(`[${moment().format("YYYY-MM-DD HH:mm:ss")}]`)} ${data.stack || data}`);
break;
case "log":
console.log(`${clk.bgBlue(`[${moment().format("YYYY-MM-DD HH:mm:ss")}]`)} ${data}`);
Expand Down
11 changes: 6 additions & 5 deletions functions/parseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ exports.getPrefix = (client, msg) => {
if (client.config.prefixMention.test(msg.content)) {
return client.config.prefixMention;
}
const prefix = msg.guildConf.prefix;
let prefix = msg.guildConf.prefix;
const escape = client.funcs.regExpEsc;
if (prefix instanceof Array) {
prefix.forEach((prefix) => {
if (msg.content.startsWith(prefix)) prefix = RegExp(`^${prefix}`);
else prefix = false;
prefix.forEach((pref) => {
if (msg.content.startsWith(pref)) prefix = pref;
else pref = false;
});
return prefix;
}
if (msg.content.startsWith(prefix)) return new RegExp(`^${prefix}`); // eslint-disable-line
if (prefix && msg.content.startsWith(prefix)) return new RegExp(`^${escape(prefix)}`); // eslint-disable-line
return false;
};
1 change: 1 addition & 0 deletions functions/regExpEsc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = str => str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
Loading

0 comments on commit 1c0f067

Please sign in to comment.