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

[BUGFIXES] More Bugfixes #122

Merged
merged 3 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- New Download Command

### Fixed
- 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.
Expand Down
8 changes: 5 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ exports.start = async (config) => {
cmd = client.commands.get(client.aliases.get(command));
}
if (!cmd) return;
const params = await client.funcs.runCommandInhibitors(client, msg, cmd)
client.funcs.runCommandInhibitors(client, msg, cmd).then((params) => {
console.log(params);
client.funcs.log(commandLog);
cmd.run(client, msg, params);
})
.catch((reason) => {
if (reason) {
if (reason.stack) client.funcs.log(reason.stack, "error");
msg.channel.sendCode("", reason).catch(console.error);
}
});
client.funcs.log(commandLog);
if (params || cmd.help.usage.length === 0) cmd.run(client, msg, params);
});

client.login(client.config.botToken);
Expand Down
13 changes: 8 additions & 5 deletions commands/System/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ const buildHelp = (client, msg) => new Promise((resolve) => {
mps.push(new Promise((res) => {
client.funcs.runCommandInhibitors(client, msg, command, [], true)
.then(() => {
const cat = command.help.category;
const subcat = command.help.subCategory;
if (!help.hasOwnProperty(cat)) help[cat] = {};
if (!help[cat].hasOwnProperty(subcat)) help[cat][subcat] = [];
help[cat][subcat].push(`${msg.guildConf.prefix}${command.help.name}${" ".repeat(longest - command.help.name.length)} :: ${command.help.description}`);
if (command.conf.permLevel <= msg.author.permLevel) {
const cat = command.help.category;
const subcat = command.help.subCategory;
if (!help.hasOwnProperty(cat)) help[cat] = {};
if (!help[cat].hasOwnProperty(subcat)) help[cat][subcat] = [];
help[cat][subcat].push(`${msg.guildConf.prefix}${command.help.name}${" ".repeat(longest - command.help.name.length)} :: ${command.help.description}`);
res();
}
res();
})
.catch(() => {
Expand Down
2 changes: 1 addition & 1 deletion functions/loadCommandInhibitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const loadCommandInhibitors = (client, baseDir) => new Promise(async (resolve, r
const files = await client.funcs.getFileListing(client, baseDir, "inhibitors").catch(err => client.funcs.log(err, "error"));
try {
files.forEach((f) => {
const props = require(`${f.path}/${f.base}`);
const props = require(`${f.path}${path.sep}${f.base}`);
client.commandInhibitors.set(f.name, props);
});
resolve();
Expand Down
2 changes: 1 addition & 1 deletion functions/loadFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const loadFunctions = (client, baseDir) => new Promise(async (resolve, reject) =
files.forEach((f) => {
const file = f.split(".");
if (file[0] === "loadFunctions") return;
client.funcs[file[0]] = require(`${dir}/${f}`);
client.funcs[file[0]] = require(`${dir}${path.sep}${f}`);
});
resolve();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion functions/loadMessageMonitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const loadMessageMonitors = (client, baseDir) => new Promise(async (resolve, rej
const files = await client.funcs.getFileListing(client, baseDir, "monitors").catch(err => client.funcs.log(err, "error"));
try {
files.forEach((f) => {
const props = require(`${f.path}/${f.base}`);
const props = require(`${f.path}${path.sep}${f.base}`);
client.messageMonitors.set(f.name, props);
});
resolve();
Expand Down
2 changes: 1 addition & 1 deletion functions/loadProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const loadProviders = (client, baseDir) => new Promise(async (resolve, reject) =
const files = await client.funcs.getFileListing(client, baseDir, "providers").catch(err => client.funcs.log(err, "error"));
try {
files.forEach((f) => {
const props = require(`${dir}/${f}`);
const props = require(`${dir}${path.sep}${f}`);
client.providers.set(f.name, props);
});
resolve();
Expand Down
6 changes: 3 additions & 3 deletions functions/loadSingleCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi
});
delete require.cache[require.resolve(loadPath)];
cmd = require(loadPath);
if (cmd.init) {
cmd.init(client);
}
} catch (e) {
reject(`Could not load existing command data: ${e.stack}`);
}
Expand All @@ -28,9 +31,6 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi
if (cmd.conf.selfbot && !client.config.selfbot) {
return reject(`The command \`${cmd.help.name}\` is only usable in selfbots!`);
}
if (cmd.init) {
cmd.init(client);
}
let pathParts = loadPath.split(path.sep);
pathParts = pathParts.slice(pathParts.indexOf("commands") + 1);
category = client.funcs.toTitleCase(cmd.help.category ? cmd.help.category : (pathParts[0] && pathParts[0].length > 0 && pathParts[0].indexOf(".") === -1 ? pathParts[0] : "General"));
Expand Down
8 changes: 5 additions & 3 deletions functions/runCommandInhibitors.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
module.exports = (client, msg, cmd) => new Promise((resolve, reject) => {
module.exports = (client, msg, cmd, args, selective = false) => new Promise((resolve, reject) => {
let usage;
const priority = client.commandInhibitors.array();
const sorted = priority.sort((a, b) => a.conf.priority > b.conf.priority);
sorted.forEach((inhib) => {
inhib.run(client, msg, cmd)
if (!cmd.conf.spamProtection && !selective) {
inhib.run(client, msg, cmd, args)
.then((value) => {
if (value) usage = value;
})
.catch((error) => {
reject(error);
});
}
});
resolve(usage);
setTimeout(() => { resolve(usage); }, 1);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "komada",
"version": "0.14.2",
"version": "0.14.3",
"author": "Evelyne Lachance",
"description": "Komada: Croatian for 'pieces', is a modular bot system including reloading modules and easy to use custom commands.",
"main": "app.js",
Expand Down