diff --git a/app.js b/app.js index 28dca295..881dc94a 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,7 @@ 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; @@ -51,8 +51,6 @@ exports.start = async (config) => { 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; }); diff --git a/classes/Config.js b/classes/Config.js index bdd01531..4a53274e 100644 --- a/classes/Config.js +++ b/classes/Config.js @@ -366,17 +366,17 @@ class Config { dataDir = resolve(`${client.clientBaseDir}${sep}bwd${sep}conf`); ensureFileAsync(`${dataDir}${sep}${defaultFile}`).catch(err => client.funcs.log(err, "error")); readJSONAsync(resolve(`${dataDir}${sep}${defaultFile}`)) - .then((conf) => { - if (conf) defaultConf = conf; - }) - .catch(() => outputJSONAsync(`${dataDir}${sep}${defaultFile}`, defaultConf)); + .then((conf) => { + if (conf) defaultConf = conf; + }) + .catch(() => outputJSONAsync(`${dataDir}${sep}${defaultFile}`, defaultConf)); client.guilds.forEach((guild) => { readJSONAsync(resolve(`${dataDir}${sep}${guild.id}.json`)) - .then((thisConf) => { - guildConfs.set(guild.id, new Config(client, guild.id, thisConf)); - }).catch(() => { - guildConfs.set(guild.id, new Config(client, guild.id, defaultConf)); - }); + .then((thisConf) => { + guildConfs.set(guild.id, new Config(client, guild.id, thisConf)); + }).catch(() => { + guildConfs.set(guild.id, new Config(client, guild.id, defaultConf)); + }); }); return null; } diff --git a/commands/System/eval.js b/commands/System/eval.js index 290f4c5a..0c80d53f 100644 --- a/commands/System/eval.js +++ b/commands/System/eval.js @@ -10,7 +10,7 @@ exports.run = (client, msg, [code]) => { } catch (err) { msg.channel.send(`\`ERROR\` \`\`\`xl\n${ client.funcs.clean(client, err) - }\n\`\`\``); + }\n\`\`\``); if (err.stack) client.funcs.log(err.stack, "error"); } }; diff --git a/commands/System/help.js b/commands/System/help.js index c7e282ec..d7eb4310 100644 --- a/commands/System/help.js +++ b/commands/System/help.js @@ -39,7 +39,7 @@ exports.run = (client, msg, [cmd]) => { } } else { msg.channel.send(helpMessage, { split: { char: "\u200b" } }) - .catch(e => client.funcs.log(e, "error")); + .catch(e => client.funcs.log(e, "error")); } }); } else if (client.commands.has(cmd)) { diff --git a/commands/System/transfer.js b/commands/System/transfer.js index 8fc288f0..e7237008 100644 --- a/commands/System/transfer.js +++ b/commands/System/transfer.js @@ -26,23 +26,23 @@ function copy(client, msg, type, name) { const clientDir = client.clientBaseDir; if (type !== "command") { copyAsync(resolve(`${coreDir}/${type}s/${name}.js`), resolve(`${clientDir}/${type}s/${name}.js`)) - .then(() => { - client.funcs.reload[type](client, client.clientBaseDir, name).catch(response => msg.edit(`:x: ${response}`)); - msg.channel.send(`:white_check_mark: Successfully Transferred ${type}: ${name}`); - }) - .catch((err) => { - msg.channel.send(`Transfer of ${type}: ${name} to Client has failed. Please check your Console.`); - client.funcs.log(err.stack, "error"); - }); + .then(() => { + client.funcs.reload[type](client, client.clientBaseDir, name).catch(response => msg.edit(`:x: ${response}`)); + msg.channel.send(`:white_check_mark: Successfully Transferred ${type}: ${name}`); + }) + .catch((err) => { + msg.channel.send(`Transfer of ${type}: ${name} to Client has failed. Please check your Console.`); + client.funcs.log(err.stack, "error"); + }); } else { copyAsync(resolve(`${coreDir}/${type}s/System/${name}.js`), resolve(`${clientDir}/${type}s/${name}.js`)) - .then(() => { - client.funcs.reload[type](client, client.clientBaseDir, name).catch(response => msg.edit(`:x: ${response}`)); - msg.channel.send(`:white_check_mark: Successfully Transferred ${type}: ${name}`); - }) - .catch((err) => { - msg.channel.send(`Transfer of ${type}: ${name} to Client has failed. Please check your Console.`); - client.funcs.log(err.stack, "error"); - }); + .then(() => { + client.funcs.reload[type](client, client.clientBaseDir, name).catch(response => msg.edit(`:x: ${response}`)); + msg.channel.send(`:white_check_mark: Successfully Transferred ${type}: ${name}`); + }) + .catch((err) => { + msg.channel.send(`Transfer of ${type}: ${name} to Client has failed. Please check your Console.`); + client.funcs.log(err.stack, "error"); + }); } } diff --git a/functions/getFileListing.js b/functions/getFileListing.js index 65ec6956..95409d8c 100644 --- a/functions/getFileListing.js +++ b/functions/getFileListing.js @@ -6,26 +6,26 @@ module.exports = (client, baseDir, type) => new Promise((res, rej) => { const files = []; try { walk(dir) - .on("data", (item) => { - const fileinfo = parse(item.path); - if (!fileinfo.ext || fileinfo.ext !== ".js") return; - files.push({ - path: fileinfo.dir, - name: fileinfo.name, - base: fileinfo.base, - ext: fileinfo.ext, - }); - }) - .on("end", () => { - res(files); - }) - .on("errors", (root, nodeStatsArray, next) => { - nodeStatsArray.forEach((n) => { - client.funcs.log(`[ERROR] " ${n.name}, "error"`); - client.funcs.log(n.error.message || (`${n.error.code}: ${n.error.path}`), "error"); - }); - next(); + .on("data", (item) => { + const fileinfo = parse(item.path); + if (!fileinfo.ext || fileinfo.ext !== ".js") return; + files.push({ + path: fileinfo.dir, + name: fileinfo.name, + base: fileinfo.base, + ext: fileinfo.ext, }); + }) + .on("end", () => { + res(files); + }) + .on("errors", (root, nodeStatsArray, next) => { + nodeStatsArray.forEach((n) => { + client.funcs.log(`[ERROR] " ${n.name}, "error"`); + client.funcs.log(n.error.message || (`${n.error.code}: ${n.error.path}`), "error"); + }); + next(); + }); } catch (err) { rej(err); } diff --git a/functions/loadSingleCommand.js b/functions/loadSingleCommand.js index 04ce3397..cfcaddea 100644 --- a/functions/loadSingleCommand.js +++ b/functions/loadSingleCommand.js @@ -42,10 +42,10 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi if (e.code === "MODULE_NOT_FOUND") { const module = /'[^']+'/g.exec(e.toString()); await client.funcs.installNPM(module[0].slice(1, -1)) - .catch((err) => { - console.error(err); - process.exit(); - }); + .catch((err) => { + console.error(err); + process.exit(); + }); client.funcs.loadSingleCommand(client, command, false, loadPath); } else { return reject(`Could not load the command: ${e.stack}`); @@ -53,17 +53,17 @@ module.exports = (client, command, reload = false, loadPath = null) => new Promi } } - // complement data from meta + // complement data from meta cmd.help.category = category; cmd.help.subCategory = subCategory; cmd.help.filePath = loadPath; - // Load Aliases + // Load Aliases cmd.conf.aliases.forEach((alias) => { client.aliases.set(alias, cmd.help.name); }); - // update help structure + // update help structure if (!client.helpStructure.has(category)) { client.helpStructure.set(category, new Map()); } diff --git a/functions/usage.js b/functions/usage.js index be6e5b4e..04646618 100644 --- a/functions/usage.js +++ b/functions/usage.js @@ -11,10 +11,10 @@ exports.run = (client, msg, cmd, args = undefined) => new Promise((resolve, reje const prefixLength = client.funcs.parseCommand(client, msg, true); if (args === undefined) { args = msg.content.slice(prefixLength) - .split(" ") - .slice(1) - .join(" ") - .split(cmd.help.usageDelim !== "" ? cmd.help.usageDelim : undefined); + .split(" ") + .slice(1) + .join(" ") + .split(cmd.help.usageDelim !== "" ? cmd.help.usageDelim : undefined); } if (args[0] === "") args = []; let currentUsage; @@ -76,19 +76,19 @@ exports.run = (client, msg, cmd, args = undefined) => new Promise((resolve, reje }); } else { msg.channel.fetchMessage(args[i]) - .then((m) => { - args[i] = m; + .then((m) => { + args[i] = m; + validateArgs(++i); + }) + .catch(() => { + if (currentUsage.type === "optional" && !repeat) { + args.splice(i, 0, undefined); validateArgs(++i); - }) - .catch(() => { - if (currentUsage.type === "optional" && !repeat) { - args.splice(i, 0, undefined); - validateArgs(++i); - } else { - args.splice(i, 1, null); - return reject(client.funcs.newError(`${currentUsage.possibles[0].name} must be a valid message id.`, 1, args)); - } - }); + } else { + args.splice(i, 1, null); + return reject(client.funcs.newError(`${currentUsage.possibles[0].name} must be a valid message id.`, 1, args)); + } + }); } } else if (currentUsage.type === "optional" && !repeat) { args.splice(i, 0, undefined); @@ -394,14 +394,14 @@ exports.run = (client, msg, cmd, args = undefined) => new Promise((resolve, reje case "message": if (/^\d+$/.test(args[i])) { msg.channel.fetchMessage(args[i]) - .then((m) => { - args[i] = m; - validated = true; - multiPossibles(++p); - }) - .catch(() => { - multiPossibles(++p); - }); + .then((m) => { + args[i] = m; + validated = true; + multiPossibles(++p); + }) + .catch(() => { + multiPossibles(++p); + }); } else { multiPossibles(++p); } diff --git a/package.json b/package.json index a54e60fa..9c9e48d6 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,7 @@ "fs-extra": "^1.0.0", "fs-extra-promise": "^0.4.1", "moment": "^2.16.0", - "moment-duration-format": "^1.3.0", - "node-i18n": "github:eslachance/node-i18n" + "moment-duration-format": "^1.3.0" }, "peerDependencies": { "dotenv": "^4.0.0" diff --git a/utils/Extendables.js b/utils/Extendables.js index e55c50ee..7777d1fb 100644 --- a/utils/Extendables.js +++ b/utils/Extendables.js @@ -2,7 +2,6 @@ const { DMChannel, GroupDMChannel, TextChannel, Message, GuildMember, Guild, Use /* A List of Extendables that allows Komada to extend native Discord.js structures to be easier or more efficient when used in Komada */ class Extendables { - /** TextBasedChannel Extendables - All of these apply to GroupDM, DM, and Guild Text Channels * .readable - Checks if a channel is readable by the client user -> returns {Boolean} * .embedable - Checks if a channel is embedable by the client user -> returns {Boolean} diff --git a/utils/loadCommandInhibitors.js b/utils/loadCommandInhibitors.js index 0852ee59..852edf43 100644 --- a/utils/loadCommandInhibitors.js +++ b/utils/loadCommandInhibitors.js @@ -19,10 +19,10 @@ const loadCommandInhibitors = (client, baseDir) => new Promise(async (res, rej) if (e.code === "MODULE_NOT_FOUND") { const module = /'[^']+'/g.exec(e.toString()); await client.funcs.installNPM(module[0].slice(1, -1)) - .catch((err) => { - console.error(err); - process.exit(); - }); + .catch((err) => { + console.error(err); + process.exit(); + }); loadCommandInhibitors(client, baseDir); } else { rej(e); diff --git a/utils/loadFunctions.js b/utils/loadFunctions.js index eec854b8..50f1e252 100644 --- a/utils/loadFunctions.js +++ b/utils/loadFunctions.js @@ -21,10 +21,10 @@ const loadFunctions = (client, baseDir) => new Promise(async (res, rej) => { if (e.code === "MODULE_NOT_FOUND") { const module = /'[^']+'/g.exec(e.toString()); await client.funcs.installNPM(module[0].slice(1, -1)) - .catch((error) => { - console.error(error); - process.exit(); - }); + .catch((error) => { + console.error(error); + process.exit(); + }); loadFunctions(client, baseDir); } else { rej(e); diff --git a/utils/loadMessageMonitors.js b/utils/loadMessageMonitors.js index 5710c97d..c51cda63 100644 --- a/utils/loadMessageMonitors.js +++ b/utils/loadMessageMonitors.js @@ -19,10 +19,10 @@ const loadMessageMonitors = (client, baseDir) => new Promise(async (res, rej) => if (e.code === "MODULE_NOT_FOUND") { const module = /'[^']+'/g.exec(e.toString()); await client.funcs.installNPM(module[0].slice(1, -1)) - .catch((err) => { - console.error(err); - process.exit(); - }); + .catch((err) => { + console.error(err); + process.exit(); + }); loadMessageMonitors(client, baseDir); } else { rej(e); diff --git a/utils/loadProviders.js b/utils/loadProviders.js index 8a1c68ad..328cf5c6 100644 --- a/utils/loadProviders.js +++ b/utils/loadProviders.js @@ -19,10 +19,10 @@ const loadProviders = (client, baseDir) => new Promise(async (res, rej) => { if (e.code === "MODULE_NOT_FOUND") { const module = /'[^']+'/g.exec(e.toString()); await client.funcs.installNPM(module[0].slice(1, -1)) - .catch((err) => { - console.error(err); - process.exit(); - }); + .catch((err) => { + console.error(err); + process.exit(); + }); loadProviders(client, baseDir); } else { rej(e);