Skip to content

Commit a26d39f

Browse files
authored
Merge pull request #49 from RTByte/dev-1.1.2
RTByte 1.1.2
2 parents 65a3218 + dc174b0 commit a26d39f

File tree

89 files changed

+1937
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1937
-388
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"es6": true
66
},
77
"parserOptions": {
8-
"ecmaVersion": 2017,
8+
"ecmaVersion": 2020,
99
"ecmaFeatures": {
1010
"experimentalObjectRestSpread": true
1111
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
package-lock.json
32
src/bwd
43
src/config.js
54
.DS_Store

package-lock.json

Lines changed: 1304 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
11
{
22
"name": "rtbyte",
3-
"version": "1.1.1a",
4-
"description": "A Discord Bot for the Rooster Teeth Community family of Discord Servers",
3+
"version": "1.1.2",
4+
"description": "An open-source modular multipurpose Discord bot built on the incredible Klasa framework for discord.js",
5+
"homepage": "https://github.com/RTByte/rtbyte/",
56
"main": "src/index.js",
67
"scripts": {
8+
"pm2:start": "pm2 start src/app.js --name rtbyte",
9+
"pm2:restart": "pm2 restart rtbyte",
10+
"pm2:logs": "pm2 logs rtbyte --lines=200",
11+
"pm2:stop": "pm2 stop rtbyte",
12+
"pm2:delete": "pm2 delete rtbyte",
713
"start": "node src/app.js",
8-
"test": "echo 'No Test Yet!'"
14+
"lint": "eslint --ext js src --fix",
15+
"test": "eslint --ext js src"
916
},
1017
"repository": {
1118
"type": "git",
12-
"url": "git@github.com:RTByte/RTByte.git"
19+
"url": "https://github.com/RTByte/rtbyte.git"
1320
},
14-
"author": "The RTByte Team",
21+
"keywords": [
22+
"discord.js",
23+
"klasa",
24+
"bot"
25+
],
26+
"contributors": [
27+
"Rasmus Gerdin <rasmus@rtbyte.xyz> (https://rasmusgerdin.com)",
28+
"Michael Cumbers <michael@rtbyte.xyz> (https://michaelcumbers.ca)",
29+
"Killian Higgins <killian@rtbyte.xyz> (https://github.com/Uzui2012)",
30+
"Justin Shull <justin@rtbyte.xyz> (https://github.com/JShull97)"
31+
],
32+
"private": true,
33+
"author": "The RTByte Team <developers@rtbyte.xyz> (https://rtbyte.xyz)",
1534
"license": "MIT",
35+
"bugs": {
36+
"url": "https://github.com/RTByte/rtbyte/issues",
37+
"email": "developers@rtbyte.xyz"
38+
},
1639
"dependencies": {
1740
"cheerio": "^1.0.0-rc.3",
1841
"discord.js": "github:discordjs/discord.js#master",
1942
"erlpack": "github:discordapp/erlpack",
20-
"klasa": "github:dirigeants/klasa#master",
21-
"klasa-member-gateway": "github:dirigeants/klasa-member-gateway#master",
43+
"fs-nextra": "^0.4.7",
44+
"klasa": "github:dirigeants/klasa#settings",
45+
"klasa-member-gateway": "github:dirigeants/klasa-member-gateway#settings",
2246
"moment": "^2.24.0",
2347
"moment-timezone": "^0.5.27",
2448
"node-fetch": "^2.3.0"

src/commands/Admin/Custom Commands/createcmd.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ module.exports = class extends Command {
77
runIn: ['text'],
88
aliases: ['addcmd', 'newcmd', 'createcommand', 'addcommand'],
99
permissionLevel: 6,
10+
requiredSettings: ['commands.customCommandsEnabled'],
1011
description: language => language.get('COMMAND_CREATECMD_DESCRIPTION'),
1112
usage: '<name:string> <content:...string>',
1213
usageDelim: ' '
1314
});
15+
this.customizeResponse('name', msg =>
16+
msg.language.get('COMMAND_CREATECMD_NOPARAM_NAME'));
17+
this.customizeResponse('content', msg =>
18+
msg.language.get('COMMAND_CREATECMD_NOPARAM_CONTENT'));
1419
}
1520

1621
async run(msg, [name, ...content]) {
22+
if (!msg.guild.settings.get('commands.customCommandsEnabled')) return msg.reject(msg.language.get('COMMAND_CREATECMD_NOTENABLED'));
23+
1724
name = name.toLowerCase();
1825
if (this.client.commands.has(name)) return msg.reject(msg.language.get('COMMAND_CUSTOM_CMD_NATIVE', name));
1926
// eslint-disable-next-line id-length
20-
const cmd = msg.guild.settings.commands.customCommands.find(c => c.name.toLowerCase() === name);
27+
const cmd = msg.guild.settings.get('commands.customCommands').find(c => c.name.toLowerCase() === name);
2128
if (cmd) return msg.reject(msg.language.get('COMMAND_CREATECMD_ALREADY_EXIST', name));
2229
await msg.guild.settings.update('commands.customCommands', { name: name, content: content.join(' ') });
2330
this.client.emit('customCmdCreate', msg, name, content);

src/commands/Admin/Custom Commands/deletecmd.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ module.exports = class extends Command {
77
runIn: ['text'],
88
aliases: ['removecmd', 'delcmd', 'deletecommand', 'removecommand'],
99
permissionLevel: 6,
10+
requiredSettings: ['commands.customCommandsEnabled'],
1011
description: language => language.get('COMMAND_DELETECMD_DESCRIPTION'),
1112
usage: '<name:string>',
1213
usageDelim: ' '
1314
});
15+
this.customizeResponse('name', msg =>
16+
msg.language.get('COMMAND_DELETECMD_NOPARAM'));
1417
}
1518

1619
async run(msg, [name]) {
20+
if (!msg.guild.settings.get('commands.customCommandsEnabled')) return msg.reject(msg.language.get('COMMAND_DELETECMD_NOTENABLED'));
21+
1722
name = name.toLowerCase();
1823
// eslint-disable-next-line id-length
19-
const cmd = msg.guild.settings.commands.customCommands.find(c => c.name.toLowerCase() === name);
24+
const cmd = msg.guild.settings.get('commands.customCommands').find(c => c.name.toLowerCase() === name);
2025
if (!cmd) return msg.reject(msg.language.get('COMMAND_CUSTOMCMD_NOT_EXIST'));
2126
await msg.guild.settings.update('commands.customCommands', cmd, { action: 'remove' });
2227
this.client.emit('customCmdDelete', msg, name);

src/commands/Admin/Custom Commands/updatecmd.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ module.exports = class extends Command {
77
runIn: ['text'],
88
aliases: ['updcmd', 'changecmd', 'updatecommand', 'changecommand', 'editcmd'],
99
permissionLevel: 6,
10+
requiredSettings: ['commands.customCommandsEnabled'],
1011
description: language => language.get('COMMAND_UPDATECMD_DESCRIPTION'),
1112
usage: '<name:string> <content:...string>',
1213
usageDelim: ' '
1314
});
15+
this.customizeResponse('name', msg =>
16+
msg.language.get('COMMAND_UPDATECMD_NOPARAM_NAME'));
17+
this.customizeResponse('content', msg =>
18+
msg.language.get('COMMAND_UPDATECMD_NOPARAM_CONTENT'));
1419
}
1520

1621
async run(msg, [name, ...content]) {
22+
if (!msg.guild.settings.get('commands.customCommandsEnabled')) return msg.reject(msg.language.get('COMMAND_UPDATECMD_NOTENABLED'));
23+
1724
name = name.toLowerCase();
1825
if (this.client.commands.has(name)) return msg.reject(msg.language.get('COMMAND_CUSTOM_CMD_NATIVE', name));
1926
// eslint-disable-next-line id-length
20-
const cmd = msg.guild.settings.commands.customCommands.find(c => c.name.toLowerCase() === name);
27+
const cmd = msg.guild.settings.get('commands.customCommands').find(c => c.name.toLowerCase() === name);
2128
if (cmd) {
2229
const oldCmd = cmd;
2330
const remove = await msg.guild.settings.update('commands.customCommands', cmd, { action: 'remove' });
24-
const add = await msg.guild.settings.update('commands.customCommands', { content: content.join(' '), name: cmd.name }, { action: 'add' });
31+
const add = await msg.guild.settings.update('commands.customCommands', { name: cmd.name, content: content.join(' ') }, { action: 'add' });
2532
if (add.errors.length || remove.errors.length) return msg.reject(msg.language.get('COMMAND_UPDATECMD_ERROR', name));
2633
this.client.emit('customCmdUpdate', msg, name, content, oldCmd);
2734
return msg.affirm();

src/commands/Admin/conf.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,53 @@ module.exports = class extends Command {
1919
throw message.language.get('COMMAND_CONF_NOKEY');
2020
})
2121
.createCustomResolver('value', (arg, possible, message, [action]) => {
22-
if (!['set', 'remove'].includes(action) || arg) return arg;
22+
if (!['set', 'remove'].includes(action)) return null;
23+
if (arg) return this.client.arguments.get('...string').run(arg, possible, message);
2324
throw message.language.get('COMMAND_CONF_NOVALUE');
2425
});
2526
}
2627

2728
show(message, [key]) {
28-
const path = this.client.gateways.guilds.getPath(key, { avoidUnconfigurable: true, errors: false, piece: null });
29-
if (!path) return message.sendLocale('COMMAND_CONF_GET_NOEXT', [key]);
30-
if (path.piece.type === 'Folder') {
29+
const entry = this.getPath(key);
30+
if (!entry || (entry.type === 'Folder' ? !entry.configurableKeys.length : !entry.configurable)) return message.sendLocale('COMMAND_CONF_GET_NOEXT', [key]);
31+
if (entry.type === 'Folder') {
3132
return message.sendLocale('COMMAND_CONF_SERVER', [
3233
key ? `: ${key.split('.').map(toTitleCase).join('/')}` : '',
33-
codeBlock('asciidoc', message.guild.settings.list(message, path.piece))
34+
codeBlock('asciidoc', message.guild.settings.display(message, entry))
3435
]);
3536
}
36-
return message.sendLocale('COMMAND_CONF_GET', [path.piece.path, message.guild.settings.resolveString(message, path.piece)]);
37+
return message.sendLocale('COMMAND_CONF_GET', [entry.path, message.guild.settings.display(message, entry)]);
3738
}
3839

39-
async set(message, [key, ...valueToSet]) {
40-
const status = await message.guild.settings.update(key, valueToSet.join(' '), message.guild, { avoidUnconfigurable: true, action: 'add' });
41-
return this.check(message, key, status) || message.sendLocale('COMMAND_CONF_UPDATED', [key, message.guild.settings.resolveString(message, status.updated[0].piece)]);
40+
async set(message, [key, valueToSet]) {
41+
const entry = this.check(message, key, await message.guild.settings.update(key, valueToSet, { onlyConfigurable: true, arrayAction: 'add' }));
42+
return message.sendLocale('COMMAND_CONF_UPDATED', [key, message.guild.settings.display(message, entry)]);
4243
}
4344

44-
async remove(message, [key, ...valueToRemove]) {
45-
const status = await message.guild.settings.update(key, valueToRemove.join(' '), message.guild, { avoidUnconfigurable: true, action: 'remove' });
46-
return this.check(message, key, status) || message.sendLocale('COMMAND_CONF_UPDATED', [key, message.guild.settings.resolveString(message, status.updated[0].piece)]);
45+
async remove(message, [key, valueToRemove]) {
46+
const entry = this.check(message, key, await message.guild.settings.update(key, valueToRemove, { onlyConfigurable: true, arrayAction: 'remove' }));
47+
return message.sendLocale('COMMAND_CONF_UPDATED', [key, message.guild.settings.display(message, entry)]);
4748
}
4849

4950
async reset(message, [key]) {
50-
const status = await message.guild.settings.reset(key, message.guild, true);
51-
return this.check(message, key, status) || message.sendLocale('COMMAND_CONF_RESET', [key, message.guild.settings.resolveString(message, status.updated[0].piece)]);
51+
const entry = this.check(message, key, await message.guild.settings.reset(key));
52+
return message.sendLocale('COMMAND_CONF_RESET', [key, message.guild.settings.display(message, entry)]);
5253
}
5354

5455
check(message, key, { errors, updated }) {
55-
if (errors.length) return message.sendMessage(String(errors[0]));
56-
if (!updated.length) return message.sendLocale('COMMAND_CONF_NOCHANGE', [key]);
57-
return null;
56+
if (errors.length) throw String(errors[0]);
57+
if (!updated.length) throw message.language.get('COMMAND_CONF_NOCHANGE', key);
58+
return updated[0].entry;
59+
}
60+
61+
getPath(key) {
62+
const { schema } = this.client.gateways.get('guilds');
63+
if (!key) return schema;
64+
try {
65+
return schema.get(key);
66+
} catch (__) {
67+
return undefined;
68+
}
5869
}
5970

6071
};

src/commands/Developer/blacklist.js renamed to src/commands/Developer/Pieces/blacklist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = class extends Command {
2121

2222
for (const userOrGuild of new Set(usersAndGuilds)) {
2323
const type = userOrGuild instanceof User ? 'user' : 'guild';
24-
if (this.client.settings[`${type}Blacklist`].includes(userOrGuild.id || userOrGuild)) {
24+
if (this.client.settings.get(`${type}Blacklist`).includes(userOrGuild.id || userOrGuild)) {
2525
changes[this.terms.indexOf(`${type}sRemoved`)].push(userOrGuild.name || userOrGuild.username || userOrGuild);
2626
} else {
2727
changes[this.terms.indexOf(`${type}sAdded`)].push(userOrGuild.name || userOrGuild.username || userOrGuild);

src/commands/Developer/Pieces/disable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = class extends Command {
1818
piece.disable();
1919
if (this.client.shard) {
2020
await this.client.shard.broadcastEval(`
21-
if (String(this.shard.id) !== '${this.client.shard.id}') this.${piece.store}.get('${piece.name}').disable();
21+
if (String(this.options.shards) !== '${this.client.options.shards}') this.${piece.store}.get('${piece.name}').disable();
2222
`);
2323
}
2424
return message.sendLocale('COMMAND_DISABLE', [piece.type, piece.name], { code: 'diff' });

0 commit comments

Comments
 (0)