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

Fixed all linting errors #271

Merged
merged 4 commits into from
Jun 17, 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
4 changes: 1 addition & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
});
Expand Down
18 changes: 9 additions & 9 deletions classes/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion commands/System/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
};
Expand Down
2 changes: 1 addition & 1 deletion commands/System/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
32 changes: 16 additions & 16 deletions commands/System/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}
}
38 changes: 19 additions & 19 deletions functions/getFileListing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions functions/loadSingleCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ 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}`);
}
}
}

// 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());
}
Expand Down
48 changes: 24 additions & 24 deletions functions/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion utils/Extendables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <GroupDMChannel|DMChannel|TextChannel>.readable - Checks if a channel is readable by the client user -> returns {Boolean}
* <GroupDMChannel|DMChannel|TextChannel>.embedable - Checks if a channel is embedable by the client user -> returns {Boolean}
Expand Down
8 changes: 4 additions & 4 deletions utils/loadCommandInhibitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions utils/loadFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions utils/loadMessageMonitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions utils/loadProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down