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

Commit

Permalink
Cutting Indev to Master for Komada 0.11.0 release (#88)
Browse files Browse the repository at this point in the history
* Travis CI

* Updated Readme

* Updated Readme

* Downgraded various errors til further notice

* ESLinting...

* More reload fixes/additions (#79)

* Command Reload - removed useless msg variables
Edited messages to better represent what they do

* Function Reload - Now able to load new pieces
Edited messages to represent what they do

* Fixed Bitwise and bumped no-nested-tern to warning

* Update Changelog

* Added License

* fixing typos in reload function (#80)

fixing typos

* The Great FS-Extra is Promisfied... Again (#82)

* ESLint override for reload.js

* Added FS-Extra-Promise dependency

* Updated guildDelete event to not need client for remove conf

* Updated confs function to use FS-Extra-Promise

* Updated loadCOmmandInhibitors function to use FS-extra-Promise

* Updated loadCommandMonitors function to use FS-extra-Promise

* Updated loadCommands function to use FS-extra-Promise

* lol forgot dependencies

* Updated loadDataProviders function to use FS-extra-Promise

* Updated loadEvents function to use FS-extra-Promise

* Updated loadFunctions function to use FS-extra-Promise

* Removed try catch, attempting to fix Promise Errors in conf function

* Multiple changes from Sync to Async

* Patch

* Changed confs.js to be async (Fixing Critical Performance Issue)

* Changed some error messages

* Removed Monitor example from Core pending Pieces.

* Initial localization implementation

Hard part: translating the strings and turn all strings to template literals...

* Fix for Clean Function (#83)

* Fix for Useless redactions

* Fix for Evies silly mess-up

* Added to Changelog

* Small adjustments to commands

help:: , commands:: don't:: work::
"are you SURE you want to reboot?" "Yes you cuck, otherwise I wouldn't have typed +reboot!"
Counts in stats are now localized to en-US (11,554)

* Usage URL Tag has been changed from Regex to Native Node URL Module. (thanks to AoDude)

* Removed debug code from usage (console.log)

* Patch Bump

* Fix in perms + arbitrary init in functions

Added fetchMember to permissionLevels (to account for invisible users).
Loop through funcs, run init if present.

* Revert "Fix in perms + arbitrary init in functions" Cause Node 7 ain't a thing for Komada yet

This reverts commit 546dcf2.

* Eval fix (#85)

* Eval fix + additions

* Added Eval Fix to Changelog

* Uh... oops..

* Changelog fixes

* Evie's Changes. But Not for Node 7 (#86)

* Added Evie's Changes but without Node 7 stuff

* Fixed permlvl resolving before fetchMembers

* Updated Changelog

* patch bump

* Fixed my error derp

* Many Additions/Changes/Deletions for Pieces && App.js (#87)

* Many Additions/Changes/Deletions for Pieces && App.js

* Removed confsRead event.

* Update CHANGELOG.md

* Minor bump

* Cutting Indev to Master for NPM 0.11.0 release
  • Loading branch information
CyberiumShadow authored Dec 9, 2016
1 parent f4c4373 commit 63eb5f5
Show file tree
Hide file tree
Showing 30 changed files with 582 additions and 394 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
"max-len": "warn",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"import/no-dynamic-require": "warn",
"no-prototype-builtins": "warn",
"no-restricted-syntax": "warn",
"guard-for-in": "warn",
"consistent-return": ["warn", { "treatUndefinedAsUnspecified": true }],
"no-use-before-define": ["warn", { "functions": true, "classes": true }],
"no-eval": "warn",
"max-len": "off"
"max-len": "off",
"no-underscore-dangle": ["error", { "allow": ["_events"] }],
"global-require": "warn",
"no-nested-ternary": "warn"
}
}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "6"
install: npm install
44 changes: 34 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.11.0] - 2016-12-9
### Added
- Travis CI

### Changed
- All pieces will now initialize their .init() function if available.
- Permissions. guild.member is now guild.fetchMember (Allows invisible users). This is Evie's addition.
- Changed `if (msg.author.bot && msg.author.id !== client.user.id) return;` back to `if (msg.author.bot) return;`
- Various Changes to commands (by Evie)
- Usage URL Tag has been changed from Regex to Native Node `URL` Module.
- confs.js is back to Async (Critical Performance bug fixed)
- Functions.js now able to reload new pieces.
- Reload.js removal of msgs.
- ESLint Errors downgraded to Warnings

### Fixed
- Pieces loading twice on standalone versions of Komada
- Critical Bug in confs.js AGAIN. (Aka me derping forgetting its a promise)
- A derp in my non Node 7 version of Evie's commit.
- Eval Now Properly Shows Errors (and Traces in Console)
- Fixed Unnecessary 'Redacted' values
- Typos
- Bitwise Ternary removal
- Updated README
- Various linting issues (still more to come)
- Fixed README errors.

### Removed
- ConfsRead event removed.
- Optional Pieces
- Herobrine

## [0.10.0] - 2016-11-21
### Added
- Reloading for Functions, Events, Inhibitors, Monitors from [UnseenFaith]
Expand All @@ -32,17 +64,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Various Confs fixes from [UnseenFaith]
- Usage Addition/ParseUsage fix from [UnseenFaith]

### Contribution Count (Latest Update)
- [UnseenFaith]: 12 contributions
- [CyberiumShadow]: 4 contributions
- [bdistin]: 1 contribution
- [hkwu]: 1 contribution
- [eslachance]: 1 contribution
- [vzwGrey]: 1 contribution


[Unreleased]: https://github.com/eslachance/komada/compare/0.10.0...HEAD
[Unreleased]: https://github.com/eslachance/komada/compare/0.11.0...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

[vzwGrey]: https://github.com/vzwGrey
[eslachance]: https://github.com/eslachance
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Discord](https://discordapp.com/api/guilds/234357395646578688/embed.png)](https://discord.gg/bRCvFy9)
[![npm](https://img.shields.io/npm/v/komada.svg?maxAge=3600)](https://www.npmjs.com/package/komada)
[![npm](https://img.shields.io/npm/dt/komada.svg?maxAge=3600)](https://www.npmjs.com/package/komada)
[![Build Status](https://travis-ci.org/eslachance/komada.svg?branch=indev)](https://travis-ci.org/eslachance/komada)
[![David](https://img.shields.io/david/eslachance/komada.svg?maxAge=3600)](https://david-dm.org/eslachance/komada)

> "Stay a while, and listen!"
Expand Down Expand Up @@ -56,7 +57,7 @@ These pieces are:
- **functions** which can be used by other pieces or anywhere in the bot.
- **inhibitors** which are used to check if a command should be run or not.
- **monitors** which are used to check a message before it's a command.
- **events**
- **events** which are triggered based on what happens in Discord.
- **dataProviders** which are database connectors (in progress at the moment).

### Creating a new command
Expand Down Expand Up @@ -102,6 +103,7 @@ by the `usage` property and its given arguments.
- **enabled**: Set to false to completely disable this command, it cannot be forcefully enabled.
- **aliases**: Array of aliases for the command, which will *also* trigger it.
- **permLevel**: Permission level, controlled via `./functions/permissionLevel.js`.
- **selfbot**: Set to true to only load this command if the bot is configured to be a selfbot.
- **botPerms**: An array of permission strings (such as `"MANAGE_MESSAGES"`) required for the command to run.
- **requiredFuncs**: An array of function names required for this command to execute (dependency).
- **usage**: The usage string as determined by the Argument Usage (see below).
Expand Down Expand Up @@ -172,7 +174,7 @@ module.exports = (str) => {
The arguments are arbitrary - just like a regular function. It may, or may not,
return anything. Basically any functions. You know what I mean.

### Creating a inhibitors
### Creating Inhibitors

Inhibitors are only ran on commands. They are used to check a variety of conditions
before a command is ever ran, such as checking if a user has the right amount of permissions
Expand All @@ -194,7 +196,7 @@ exports.run = (client, msg, cmd) => {

> Note: The order does not matter.
### Creating a monitors
### Creating Monitors

Monitors are special in that they will always run on any message. This is particularly
useful when you need to do checking on the message, such as checking if a message
Expand Down
14 changes: 4 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@ exports.start = (config) => {
client.funcs.loadCommandInhibitors(client);
client.funcs.loadCommandMonitors(client);
client.funcs.loadEvents(client);
client.i18n = client.funcs.loadLocalizations;
client.i18n.init(client);
});

client.once("ready", () => {
client.config.prefixMention = new RegExp(`^<@!?${client.user.id}>`);
client.funcs.confs.init(client);
});

client.once("confsRead", () => {
client.commands.forEach((command) => {
if (command.init) {
command.init(client);
}
});
});

client.on("message", (msg) => {
if (msg.author.bot && msg.author.id !== client.user.id) return;
if (msg.author.bot) return;
const conf = client.funcs.confs.get(msg.guild);
msg.guildConf = conf;
client.i18n.use(conf.lang);
client.funcs.runCommandMonitors(client, msg).catch(reason => msg.channel.sendMessage(reason).catch(console.error));
if (!msg.content.startsWith(conf.prefix) && !client.config.prefixMention.test(msg.content)) return;
let prefixLength = conf.prefix.length;
Expand Down
3 changes: 2 additions & 1 deletion commands/System/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ exports.run = (client, msg, [code]) => {
msg.channel.sendCode("xl", client.funcs.clean(client, evaled));
} catch (err) {
msg.channel.sendMessage(`\`ERROR\` \`\`\`xl\n${
client.funcs.clean(err)
client.funcs.clean(client, err)
}\n\`\`\``);
if (err.stack) client.funcs.log(err.stack, "error");
}
};

Expand Down
4 changes: 2 additions & 2 deletions commands/System/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const buildHelp = (client, msg) => new Promise((resolve) => {
const mps = [];

const commandNames = Array.from(client.commands.keys());
const longest = commandNames.reduce((longest, str) => Math.max(longest, str.length), 0);
const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);

client.commands.forEach((command) => {
mps.push(new Promise((res) => {
Expand All @@ -50,7 +50,7 @@ const buildHelp = (client, msg) => new Promise((resolve) => {
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}`);
help[cat][subcat].push(`${msg.guildConf.prefix}${command.help.name}${" ".repeat(longest - command.help.name.length)} :: ${command.help.description}`);
res();
})
.catch(() => {
Expand Down
36 changes: 13 additions & 23 deletions commands/System/reboot.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
exports.run = (client, msg) => {
const collector = msg.channel.createCollector(m => m.author === msg.author, {
time: 10000,
});
msg.channel.sendMessage("are you sure?");
collector.on("message", (m) => {
if (m.content === "no") collector.stop("aborted");
if (m.content === "yes") collector.stop("success");
});
collector.on("end", (collected, reason) => {
if (reason === "time") return msg.channel.sendMessage("The prompt timed out...");
if (reason === "aborted") return msg.channel.sendMessage("The reboot has been aborted");
if (reason === "success") {
msg.channel.sendMessage("Rebooting...")
.then(() => {
process.exit();
})
.catch((e) => {
console.error(e);
});
}
return true;
});
msg.channel.sendMessage("Rebooting...")
.then(() => {
process.exit();
})
.catch((e) => {
console.error(e);
});
};

exports.conf = {
Expand All @@ -34,7 +19,12 @@ exports.conf = {

exports.help = {
name: "reboot",
description: "reboots the bot.",
description: "Reboots the bot.",
usage: "",
usageDelim: "",
};

exports.strings = {
"Reboots the bot.": "Redémarre le bot",
"Rebooting...": "Redémarrage",
};
37 changes: 19 additions & 18 deletions commands/System/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@ exports.run = (client, msg, [type, name]) => {
switch (type) {
case "function":
msg.channel.sendMessage(`Attemping to reload function ${name}`).then((m) => {
client.funcs.reload.function(client, msg, client.clientBaseDir, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded function ${name}`);
client.funcs.reload.function(client, client.clientBaseDir, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
case "inhibitor":
msg.channel.sendMessage(`Attempting to reload inhibitor ${name}`).then((m) => {
client.funcs.reload.inhibitor(client, msg, client.clientBaseDir, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded inhibitor ${name}`);
client.funcs.reload.inhibitor(client, client.clientBaseDir, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
case "monitor":
msg.channel.sendMessage(`Attempting to reload monitor ${name}`).then((m) => {
client.funcs.reload.monitor(client, msg, client.clientBaseDir, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded monitor ${name}`);
client.funcs.reload.monitor(client, client.clientBaseDir, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
case "provider":
msg.channel.sendMessage(`Attempting to reload provider ${name}`).then((m) => {
client.funcs.reload.provider(client, msg, client.clientBaseDir, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded provider ${name}`);
client.funcs.reload.provider(client, client.clientBaseDir, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
case "event":
msg.channel.sendMessage(`Attempting to reload event ${name}`).then((m) => {
client.funcs.reload.event(client, msg, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded event ${name}`);
client.funcs.reload.event(client, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
Expand All @@ -53,15 +53,16 @@ exports.run = (client, msg, [type, name]) => {
break;
default:
msg.channel.sendMessage(`Attempting to reload command ${name}`).then((m) => {
client.funcs.reload.command(client, msg, client.clientBaseDir, name).then(() => {
m.edit(`:white_check_mark: Succesfully reloaded command ${name}`);
client.funcs.reload.command(client, client.clientBaseDir, name).then((message) => {
m.edit(`:white_check_mark: ${message}`);
}).catch((e) => {
m.edit(e);
m.edit(`:x: ${e}`);
});
});
break;
}
break;
// no default
}
};

Expand Down
6 changes: 3 additions & 3 deletions commands/System/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
• Mem Usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB
• Uptime :: ${duration}
• Users :: ${client.users.size}
• Servers :: ${client.guilds.size}
• Channels :: ${client.channels.size}
• Users :: ${client.users.size.toLocaleString()}
• Servers :: ${client.guilds.size.toLocaleString()}
• Channels :: ${client.channels.size.toLocaleString()}
• Komada :: ${komada.version}
• Discord.js :: v${Discord.version}`);
};
Expand Down
2 changes: 1 addition & 1 deletion events/guildDelete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.run = (client, guild) => {
if (!guild.available) return;
client.funcs.confs.remove(client, guild);
client.funcs.confs.remove(guild);
};
5 changes: 4 additions & 1 deletion functions/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ function sensitivePattern(client) {

module.exports = (client, text) => {
if (typeof (text) === "string") {
return text.replace(sensitivePattern(client), "「redacted」").replace(client.user.email, "「redacted」").replace(/`/g, `\`${String.fromCharCode(8203)}`).replace(/@/g, `@${String.fromCharCode(8203)}`);
if (client.user.email) {
text.replace(client.user.email, "「redacted」");
}
return text.replace(sensitivePattern(client), "「redacted」").replace(/`/g, `\`${String.fromCharCode(8203)}`).replace(/@/g, `@${String.fromCharCode(8203)}`);
}
return text;
};
Loading

0 comments on commit 63eb5f5

Please sign in to comment.