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

Cutting Indev to Master for NPM 0.10.0 release #76

Merged
merged 66 commits into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9e7c34a
Added padding to help command
Oct 24, 2016
dd2a5f9
Removed one line function
Oct 26, 2016
9c2371b
eh!?
Oct 29, 2016
ca34bf8
Added padding to help command
Oct 29, 2016
220d4da
Merge pull request #55 from vzwGrey/master
eslachance Oct 29, 2016
ad48002
Custom Permission Roles Support
UnseenFaith Oct 29, 2016
e227e5a
Adds member usage type.
UnseenFaith Oct 29, 2016
e881ad2
parseUsage fix and member usage type
UnseenFaith Oct 29, 2016
fb9ca6c
Merge pull request #57 from UnseenFaith/faith-patch-1
eslachance Oct 30, 2016
9997a89
Merge pull request #58 from UnseenFaith/faith-patch-2
eslachance Oct 30, 2016
12524f6
Allows multi word values to be used
CyberiumShadow Oct 30, 2016
1e083ec
Fix random missing periods, spelling, etc.
hkwu Oct 30, 2016
adcd95a
Merge pull request #60 from CyberiumShadow/patch-conf
eslachance Oct 30, 2016
6f0d01d
Merge pull request #61 from hkwu/patch-1
eslachance Oct 30, 2016
a58b395
bot owner commands only...
eslachance Oct 30, 2016
35f50d9
Merged branch indev into indev
eslachance Oct 30, 2016
b66a126
Fix for Core 'conf' command
UnseenFaith Oct 31, 2016
ca28d66
Adds Boolean Usage type and reverts old boolean fix
UnseenFaith Oct 31, 2016
60e33cd
Reverted again and made value checking better.
UnseenFaith Nov 1, 2016
f32faec
Quick fix for disable.js not disabling commands in
UnseenFaith Nov 1, 2016
f059389
Merge pull request #62 from UnseenFaith/faith-patch-3
eslachance Nov 1, 2016
760aaca
Fix for default config being 'out of sync' on updates
UnseenFaith Nov 3, 2016
042ac9e
Better 'Fix', which allow you to use setKey, and not
UnseenFaith Nov 3, 2016
0624db4
Updated forEach per Ao's recommendation
UnseenFaith Nov 3, 2016
5ca8325
Merge pull request #63 from UnseenFaith/faith-patch-5
CyberiumShadow Nov 3, 2016
f4d2a15
Download.js VM "Cannot Find Module" Fix
UnseenFaith Nov 3, 2016
d6f1ac7
Readded Cybers selfbot option && fix for it
UnseenFaith Nov 3, 2016
e1942cf
If command is now selfbot only and bot is not a selfbot,
UnseenFaith Nov 3, 2016
10e8e7a
Selfbot commands now correctly load or not if selfbot
UnseenFaith Nov 3, 2016
5700176
Merge pull request #64 from UnseenFaith/faith-patch-6
CyberiumShadow Nov 7, 2016
1d868b8
Bumping Komada Core to use D.JS Indev
CyberiumShadow Nov 8, 2016
cea3156
Eslint/Beautify everything~
CyberiumShadow Nov 8, 2016
9ccdbff
Updated ESLint to allow Template Literals
CyberiumShadow Nov 8, 2016
5c05aa7
Fix Resolves/Rejects to stop executing further code
bdistin Nov 10, 2016
48f2966
Delete .jsbeautifyrc
CyberiumShadow Nov 18, 2016
17d767e
Update .eslintrc.json
CyberiumShadow Nov 18, 2016
7c1bcd8
Update package.json
CyberiumShadow Nov 18, 2016
7fbb90b
Update package.json
CyberiumShadow Nov 18, 2016
c0fca36
Various Changes.
CyberiumShadow Nov 18, 2016
1f7aa4d
Update .eslintrc.json
CyberiumShadow Nov 18, 2016
a496543
Fixed
CyberiumShadow Nov 18, 2016
3aeb37e
Conf.js Fix && Eslint
UnseenFaith Nov 19, 2016
a7407d9
Merge pull request #68 from UnseenFaith/faith-patch
CyberiumShadow Nov 19, 2016
4dffe89
The Great Conf Fix
UnseenFaith Nov 19, 2016
e891614
Update confs.js
CyberiumShadow Nov 19, 2016
dbc334f
Merge pull request #69 from UnseenFaith/confs-fix
CyberiumShadow Nov 19, 2016
b2299fb
Eslinting Patch
UnseenFaith Nov 19, 2016
1b5420a
Merge pull request #70 from UnseenFaith/eslinting-patch
CyberiumShadow Nov 19, 2016
7eb0db6
ESlint them all
CyberiumShadow Nov 19, 2016
de82234
Fucked up?
CyberiumShadow Nov 19, 2016
d5c9885
Semver Patch
CyberiumShadow Nov 19, 2016
c31f664
Fixes
CyberiumShadow Nov 19, 2016
4ca7374
Bumped
CyberiumShadow Nov 19, 2016
b396018
Monitors addition (#71)
UnseenFaith Nov 19, 2016
d01be70
Better Support for Arrays/Ints/Booleans/Strings
UnseenFaith Nov 20, 2016
228314e
Update package.json
CyberiumShadow Nov 20, 2016
66849b7
Monitors/Inhibitors Uncaught Exception fix
UnseenFaith Nov 20, 2016
e0eebdb
Verison Bumps
CyberiumShadow Nov 20, 2016
d47a782
Merge pull request #72 from UnseenFaith/confs-better-support
CyberiumShadow Nov 20, 2016
bf25f6c
Merge pull request #73 from UnseenFaith/loading-functions-fixes
CyberiumShadow Nov 20, 2016
62920f7
Fixes Galore
CyberiumShadow Nov 20, 2016
32f475f
Aye Fixed Komada not listening to itself
CyberiumShadow Nov 20, 2016
880d1c1
Reload all the things! (#75)
UnseenFaith Nov 21, 2016
cd5732b
Create CHANGELOG.MD
CyberiumShadow Nov 21, 2016
29360cf
Rename CHANGELOG.MD to CHANGELOG.md
CyberiumShadow Nov 21, 2016
5a0795b
Changelog Released.
CyberiumShadow Nov 21, 2016
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
23 changes: 18 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": { "sourceType": "module" },
"extends": "airbnb-base",
"rules": {
"no-console": "off",
"indent": ["error", 2, { "SwitchCase": 1 } ],
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": "off",
"quotes": [ "warn", "double" ],
"semi": [ "warn", "always" ]
"quotes": ["warn", "double"],
"semi": ["warn", "always"],
"no-param-reassign": "off",
"no-shadow": "warn",
"no-plusplus": "off",
"radix": ["error", "as-needed"],
"max-len": "warn",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"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"
}
}
30 changes: 0 additions & 30 deletions .jsbeautifyrc

This file was deleted.

52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.10.0] - 2016-11-21
### Added
- Reloading for Functions, Events, Inhibitors, Monitors from [UnseenFaith]
- Monitors from [UnseenFaith]
- ESLint Rules added from [CyberiumShadow] and [hkwu]
- Discord.JS Indev Support from [CyberiumShadow]
- Custom Permissions Roles from [UnseenFaith]

### Changed
- New Reload.js Command. from [UnseenFaith]
- Komada no longer listens to bots. from [CyberiumShadow]
- Better support for Arrays/Ints/Booleans/Strings in confs from [UnseenFaith]
- Changing commands to bot owner only. from [eslachance]
- Allowing multiword values to be used in confs from [CyberiumShadow]
- Padding from [vzwGrey]

### Fixed
- Fixes for Function/Command reload.js from [UnseenFaith]
- Fixes last eslint issues and codeblock undefined issue from [UnseenFaith]
- Monitors/Inhibitors Uncaught Exception fix from [UnseenFaith]
- The Great Conf Fix from [UnseenFaith]
- Fixed Promise Resolve/Rejects to prevent further code execution from [bdistin]
- Download.js VM "Cannot Find Module" Fix from [UnseenFaith]
- 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/v0.10.0...HEAD
[0.10.0]: https://github.com/eslachance/komada/compare/1627e6deb1d8c352d83e52ccd590f2330f5f8bb2...v0.10.0

[vzwGrey]: https://github.com/vzwGrey
[eslachance]: https://github.com/eslachance
[hkwu]: https://github.com/hkwu
[bdistin]: https://github.com/bdistin
[UnseenFaith]: https://github.com/UnseenFaith
[CyberiumShadow]: https://github.com/CyberiumShadow
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ npm install
node app.js
```

> Requires Node 6 or higher (because discord.js requires that), also requires Discord.js v10 (currently #indev), installed automatically with `npm install`.
> Requires Node 6 or higher (because Discord.js requires that), also requires Discord.js v10, installed automatically with `npm install`.

## Quick & Dirty Reference Guide
> For creating your own pieces

Essentially, the way Komada works is that we have *core* pieces (functions, events, commands, etc) loaded automatically.
But you can add your own pieces easily by adding files to your *local* folders (which are created on first load)
Essentially, the way Komada works is that we have *core* pieces (functions, events, commands, etc.) loaded automatically.
But you can add your own pieces easily by adding files to your *local* folders (which are created on first load).

These pieces are:
- **Commands** which add in-chat functionality to your bot
These pieces are:
- **commands** which add in-chat functionality to your bot.
- **functions** which can be used by other pieces or anywhere in the bot.
- **dataHandlers** which are database connectors (in progress at the moment)
- **dataHandlers** which are database connectors (in progress at the moment).

### Creating a new command

Expand All @@ -64,12 +64,12 @@ the categories offered in the help command. For instance adding `./commands/Misc
will create a command named `test` in the `Misc` category. Subcategories can
also be created by adding a second folder level.

> If a command is present both in the *core* folders and your client folders,
> If a command is present both in the *core* folders and your client folders,
your command will override the core one. This can let you modify the core
behaviour. Note also that you cannot have more than one command with the same name.

```js
exports.run = (client, msg. [...args]) => {
exports.run = (client, msg, [...args]) => {
// Place Code Here
};

Expand All @@ -94,13 +94,13 @@ exports.help = {
run. The name of the arguments in the array (and their count) is determined
by the `usage` property and its given arguments.

**Non-obvious options**:
**Non-obvious options**:
- **enabled**: Set to false to completely disable this command, it cannot be forecefully enabled.
- **aliases**: Array of aliases for the command, which will *also* trigger it.
- **permLevel**: Permission level, controlled via `./functions/permissionLevel.js`
- **permLevel**: Permission level, controlled via `./functions/permissionLevel.js`.
- **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)
- **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).

#### Command Arguments

Expand All @@ -110,22 +110,22 @@ by the `usage` property and its given arguments.
`<Name:Type{min,max}>`

- **Name** Mostly used for debugging message, unless the type is Litteral in which it compares the argument to the name.
- **Type** The type of variable you are expecting
- **Type** The type of variable you are expecting.
- **Min, Max** Minimum or Maximum for a giving variable (works on strings in terms of length, and on all types of numbers in terms of value) You are allowed to define any combination of min and max. Omit for none, `{min}` for min, `{,max}` for max.
- **Special Repeat Tag** `[...]` will repeat the last usage optionally until you run out of arguments. Useful for doing something like `<SearchTerm:str> [...]` which will allow you to take as many search terms as you want, per your Usage Deliminator.
- **Special Repeat Tag** `[...]` will repeat the last usage optionally until you run out of arguments. Useful for doing something like `<SearchTerm:str> [...]` which will allow you to take as many search terms as you want, per your Usage Delimiter.

**Usage Types**

- `literal` : Literally equal to the Name. This is the default type if none is defined.
- `str`, `string` : Strings
- `int`, `integer` : Integers
- `num`, `number`, `Float` : Floating point numbers
- `url` : a url
- `msg`, `message` : A message object returned from the message id (now using fetchMessage as of d3d498c99d5eca98b5cbcefb9838fa7d96f17c93)
- `channel` : A channel object returned from the channel id or channel tag
- `guild` : A guild object returned from the guild id
- `user`, `mention` : A user object returned from the user id or mention
- `str`, `string` : Strings.
- `int`, `integer` : Integers.
- `num`, `number`, `Float` : Floating point numbers.
- `url` : A URL.
- `msg`, `message` : A message object returned from the message ID (now using fetchMessage as of d3d498c99d5eca98b5cbcefb9838fa7d96f17c93).
- `channel` : A channel object returned from the channel ID or channel tag.
- `guild` : A guild object returned from the guild ID.
- `user`, `mention` : A user object returned from the user ID or mention.

### Creating an event

Events are placed in `./events/` and their filename must be `eventName.js`.
Expand All @@ -140,8 +140,8 @@ exports.run = (client, [...args]) => {
};
```

Where `[...args]` is arguments you would *normally* get from those events.
For example, while the `ready` event would only have `(client)`, the
Where `[...args]` are arguments you would *normally* get from those events.
For example, while the `ready` event would only have `(client)`, the
`guildMemberAdd` event would be `(guild, member)`.

### Creating a function
Expand All @@ -164,4 +164,4 @@ 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.
return anything. Basically any functions. You know what I mean.
55 changes: 30 additions & 25 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
const Discord = require("discord.js");
const chalk = require("chalk");
const loadFunctions = require("./functions/loadFunctions.js");

const clk = new chalk.constructor({ enabled: true });

exports.start = (config) => {

const client = new Discord.Client(config.clientOptions);

client.config = config;

// Extend client
client.config["init"] = [];
client.config.init = [];
client.funcs = {};
client.helpStructure = new Map();
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.commandInhibitors = new Discord.Collection();
client.commandMonitors = new Discord.Collection();
client.dataProviders = new Discord.Collection();

client.coreBaseDir = __dirname + "/";
client.clientBaseDir = process.cwd() + "/";
client.coreBaseDir = `${__dirname}/`;
client.clientBaseDir = `${process.cwd()}/`;

// Load core functions, then everything else
require("./functions/loadFunctions.js")(client).then(() => {
loadFunctions(client).then(() => {
client.funcs.loadDataProviders(client);
client.funcs.loadCommands(client);
client.funcs.loadCommandInhibitors(client);
client.funcs.loadCommandMonitors(client);
client.funcs.loadEvents(client);
});

Expand All @@ -34,48 +37,50 @@ exports.start = (config) => {
});

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

client.on("message", msg => {
let conf = client.funcs.confs.get(msg.guild);
client.on("message", (msg) => {
if (msg.author.bot && msg.author.id !== client.user.id) return;
const conf = client.funcs.confs.get(msg.guild);
msg.guildConf = conf;
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;
if(client.config.prefixMention.test(msg.content)) prefixLength = client.config.prefixMention.exec(msg.content)[0].length +1;
let command = msg.content.slice(prefixLength).split(" ")[0].toLowerCase();
let suffix = msg.content.slice(prefixLength).split(" ").slice(1).join(" ");
if (client.config.prefixMention.test(msg.content)) prefixLength = client.config.prefixMention.exec(msg.content)[0].length + 1;
const command = msg.content.slice(prefixLength).split(" ")[0].toLowerCase();
const suffix = msg.content.slice(prefixLength).split(" ").slice(1).join(" ");
let commandLog;
switch (msg.channel.type) {
case "text":
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix ? suffix : ""}') => ${clk.bgGreen(`${msg.guild.name}[${msg.guild.id}]`)}`;
break;
case "dm":
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix ? suffix : ""}') => ${clk.bgMagenta("[Direct Messages]")}`;
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix}') => ${clk.bgMagenta("[Direct Messages]")}`;
break;
case "group": //works for selfbots only
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix ? suffix : ""}') => ${clk.bgCyan(`${msg.channel.owner.username}[${msg.channel.owner.id}] in [GroupDM]`)}`;
case "group": // works for selfbots only
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix}') => ${clk.bgCyan(`${msg.channel.owner.username}[${msg.channel.owner.id}] in [GroupDM]`)}`;
break;
default: // text channels
commandLog = `${clk.black.bgYellow(`${msg.author.username}<@${msg.author.id}>`)} : ${clk.bold(command)}('${suffix}') => ${clk.bgGreen(`${msg.guild.name}[${msg.guild.id}]`)}`;
}
let cmd;
if (client.commands.has(command)) {
cmd = client.commands.get(command);
} else if (client.aliases.has(command)) {
cmd = client.commands.get(client.aliases.get(command));
}
if(!cmd) return;
if (!cmd) return;
client.funcs.runCommandInhibitors(client, msg, cmd)
.then(params => {
.then((params) => {
client.funcs.log(commandLog);
cmd.run(client, msg, params);
})
.catch(reason => {
if(reason) {
msg.channel.sendMessage(reason).catch(console.error);
.catch((reason) => {
if (reason) {
if (reason.stack) client.funcs.log(reason.stack, "error");
msg.channel.sendCode("", reason).catch(console.error);
}
});
});
Expand All @@ -84,6 +89,6 @@ exports.start = (config) => {
return client;
};

process.on("unhandledRejection", err => {
console.error("Uncaught Promise Error: \n" + err.stack);
process.on("unhandledRejection", (err) => {
console.error(`Uncaught Promise Error: \n${err.stack}`);
});
Loading