diff --git a/.gitignore b/.gitignore
index c2658d7d..5dfafe18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,11 @@
-node_modules/
+# Logs
+logs
+*.log
+npm-debug.log*
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
+node_modules
diff --git a/Procfile b/Procfile
index 8632a70a..73f47d28 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-worker: node shardingmanager.js
+worker: node Shard.js
diff --git a/README.md b/README.md
index 26290ecd..e30ea3ee 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,17 @@
# XiaoBot
[](https://discord.gg/fqQF8mc)
-Public Source Code for the Discord Bot XiaoBot, a Discord bot coded in JavaScript with [discord.js](https://github.com/hydrabolt/discord.js) using the [Commando](https://github.com/Gawdl3y/discord.js-commando) command framework.
+Public Source Code for the Discord Bot XiaoBot, a Discord bot coded in
+JavaScript with [discord.js](https://github.com/hydrabolt/discord.js) using the
+[Commando](https://github.com/Gawdl3y/discord.js-commando) command framework.
## Adding it to Your Server
-You can add XiaoBot to your server with [this link](https://discordapp.com/oauth2/authorize?client_id=278305350804045834&scope=bot&permissions=1345846343).
+Visit XiaoBot's page on the Discord Bots list, which is quite fancy, with
+[this link](https://bots.discord.pw/bots/278305350804045834).
## Home Server
You can join the home server with [this link](https://discord.gg/fqQF8mc).
## Licensing
-The bot is licensed under an [ISC License](https://opensource.org/licenses/ISC). See the file `LICENSE.md` for more information.
+The bot is licensed under an [ISC License](https://opensource.org/licenses/ISC).
+See the file `LICENSE.md` for more information.
diff --git a/shardingmanager.js b/Shard.js
similarity index 58%
rename from shardingmanager.js
rename to Shard.js
index d911ef83..eaab8bef 100644
--- a/shardingmanager.js
+++ b/Shard.js
@@ -1,4 +1,4 @@
const { ShardingManager } = require('discord.js');
const { TOKEN } = process.env;
-const Manager = new ShardingManager('./index.js', { token: TOKEN });
+const Manager = new ShardingManager('./XiaoBot.js', { token: TOKEN });
Manager.spawn(2);
diff --git a/index.js b/XiaoBot.js
similarity index 89%
rename from index.js
rename to XiaoBot.js
index 39f012fe..d660c32f 100644
--- a/index.js
+++ b/XiaoBot.js
@@ -1,5 +1,7 @@
-const { TOKEN, OWNER, PREFIX, INVITE, CLEVS_KEY, CLEVS_USER, CLEVS_NICK } = process.env;
-const { CommandoClient, FriendlyError } = require('discord.js-commando');
+const { TOKEN, OWNER, PREFIX, INVITE } = process.env;
+const path = require('path');
+const { FriendlyError } = require('discord.js-commando');
+const CommandoClient = require('./structures/CommandoClient');
const client = new CommandoClient({
commandPrefix: PREFIX,
owner: OWNER,
@@ -8,21 +10,10 @@ const client = new CommandoClient({
unknownCommandResponse: false
});
const { RichEmbed } = require('discord.js');
-const path = require('path');
const { carbon, dBots } = require('./structures/Stats');
const SequelizeProvider = require('./providers/Sequelize');
-const Database = require('./structures/PostgreSQL');
-const Cleverbot = require('cleverio');
-const clevs = new Cleverbot({
- key: CLEVS_KEY,
- user: CLEVS_USER,
- nick: CLEVS_NICK
-});
-Database.start();
-clevs.create();
-
-client.setProvider(new SequelizeProvider(Database.db));
+client.setProvider(new SequelizeProvider(client.database));
client.registry
.registerDefaultTypes()
@@ -45,11 +36,9 @@ client.registry
.registerDefaultCommands({ help: false })
.registerCommandsIn(path.join(__dirname, 'commands'));
-let mention;
client.on('ready', () => {
console.log(`[Ready] Shard ${client.shard.id} Logged in!`);
client.user.setGame(`x;help | Shard ${client.shard.id}`);
- mention = new RegExp(`()`, 'g');
});
client.on('disconnect', (event) => {
@@ -66,6 +55,17 @@ client.on('commandError', (command, err) => {
console.error(command.name, err);
});
+client.dispatcher.addInhibitor(msg => {
+ if (msg.channel.type === 'dm') return false;
+ const role = msg.guild.settings.get('singleRole');
+ if (!role) return false;
+ if (!msg.guild.roles.has(role)) return false;
+ if (client.isOwner(msg.author)) return false;
+ if (msg.member.hasPermission('ADMINISTRATOR')) return false;
+ if (!msg.member.roles.has(role))
+ return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)];
+});
+
client.on('message', async (msg) => {
if (msg.guild && msg.guild.settings.get('inviteGuard') && /(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) {
if (msg.author.bot ||
@@ -85,9 +85,9 @@ client.on('message', async (msg) => {
if (role && !msg.member.roles.has(role)) return;
}
msg.channel.startTyping();
- const message = msg.content.replace(mention, '');
+ const message = msg.content.replace(client.mentionRegex, '');
try {
- const { response } = await clevs.ask(message);
+ const { response } = await client.cleverbot.ask(message);
return msg.reply(response)
.then(() => msg.channel.stopTyping());
} catch (err) {
@@ -119,16 +119,6 @@ client.on('messageReactionAdd', (reaction, user) => {
return channel.send({ embed });
});
-client.dispatcher.addInhibitor(msg => {
- if (msg.channel.type === 'dm') return false;
- const role = msg.guild.settings.get('singleRole');
- if (!role) return false;
- if (client.isOwner(msg.author)) return false;
- if (msg.member.hasPermission('ADMINISTRATOR')) return false;
- if (!msg.member.roles.has(role))
- return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)];
-});
-
client.on('guildMemberAdd', (member) => {
const role = member.guild.roles.get(member.guild.settings.get('joinRole'));
if (member.guild.me.hasPermission('MANAGE_ROLES') && role)
@@ -158,7 +148,6 @@ client.on('guildCreate', async (guild) => {
console.log(`[Guild] I have joined ${guild.name}! (${guild.id})`);
const guilds = await client.shard.fetchClientValues('guilds.size');
const count = guilds.reduce((prev, val) => prev + val, 0);
- console.log(`[Count] ${count}`);
carbon(count);
dBots(count, client.user.id);
});
@@ -167,7 +156,6 @@ client.on('guildDelete', async (guild) => {
console.log(`[Guild] I have left ${guild.name}... (${guild.id})`);
const guilds = await client.shard.fetchClientValues('guilds.size');
const count = guilds.reduce((prev, val) => prev + val, 0);
- console.log(`[Count] ${count}`);
carbon(count);
dBots(count, client.user.id);
});
diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000-years.js
similarity index 100%
rename from commands/avataredit/3000years.js
rename to commands/avataredit/3000-years.js
diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bob-ross.js
similarity index 100%
rename from commands/avataredit/bobross.js
rename to commands/avataredit/bob-ross.js
diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steam-card.js
similarity index 100%
rename from commands/avataredit/steamcard.js
rename to commands/avataredit/steam-card.js
diff --git a/commands/games/mathgame.js b/commands/games/math-game.js
similarity index 100%
rename from commands/games/mathgame.js
rename to commands/games/math-game.js
diff --git a/commands/games/rockpaperscissors.js b/commands/games/rock-paper-scissors.js
similarity index 100%
rename from commands/games/rockpaperscissors.js
rename to commands/games/rock-paper-scissors.js
diff --git a/commands/games/typinggame.js b/commands/games/typing-game.js
similarity index 100%
rename from commands/games/typinggame.js
rename to commands/games/typing-game.js
diff --git a/commands/guildinfo/guildinfo.js b/commands/guildinfo/server-info.js
similarity index 92%
rename from commands/guildinfo/guildinfo.js
rename to commands/guildinfo/server-info.js
index 75333a2d..ee92017e 100644
--- a/commands/guildinfo/guildinfo.js
+++ b/commands/guildinfo/server-info.js
@@ -7,10 +7,10 @@ require('moment-duration-format');
module.exports = class GuildInfoCommand extends Command {
constructor(client) {
super(client, {
- name: 'server',
- aliases: ['guild', 'server-info', 'guild-info'],
+ name: 'server-info',
+ aliases: ['guild', 'server', 'guild-info'],
group: 'guildinfo',
- memberName: 'server',
+ memberName: 'server-info',
description: 'Gives some info on the current server.',
guildOnly: true
});
diff --git a/commands/random/easteregg.js b/commands/random/easter-egg.js
similarity index 100%
rename from commands/random/easteregg.js
rename to commands/random/easter-egg.js
diff --git a/commands/random/giveflower.js b/commands/random/give-flower.js
similarity index 100%
rename from commands/random/giveflower.js
rename to commands/random/give-flower.js
diff --git a/commands/random/wouldyourather.js b/commands/random/would-you-rather.js
similarity index 100%
rename from commands/random/wouldyourather.js
rename to commands/random/would-you-rather.js
diff --git a/commands/randomimg/xiaopai.js b/commands/randomimg/xiao-pai.js
similarity index 100%
rename from commands/randomimg/xiaopai.js
rename to commands/randomimg/xiao-pai.js
diff --git a/commands/response/8ball.js b/commands/response/8-ball.js
similarity index 100%
rename from commands/response/8ball.js
rename to commands/response/8-ball.js
diff --git a/commands/response/factcore.js b/commands/response/fact-core.js
similarity index 100%
rename from commands/response/factcore.js
rename to commands/response/fact-core.js
diff --git a/commands/response/magicconch.js b/commands/response/magic-conch.js
similarity index 100%
rename from commands/response/magicconch.js
rename to commands/response/magic-conch.js
diff --git a/commands/response/quantumcoin.js b/commands/response/quantum-coin.js
similarity index 94%
rename from commands/response/quantumcoin.js
rename to commands/response/quantum-coin.js
index a001c4aa..f3e52505 100644
--- a/commands/response/quantumcoin.js
+++ b/commands/response/quantum-coin.js
@@ -5,7 +5,7 @@ module.exports = class QuantumCoinCommand extends Command {
constructor(client) {
super(client, {
name: 'quantum-coin',
- aliases: ['qcoin'],
+ aliases: ['q-coin'],
group: 'response',
memberName: 'quantum-coin',
description: 'Flips a coin that lands on nothing.'
diff --git a/commands/response/ratewaifu.js b/commands/response/rate-waifu.js
similarity index 100%
rename from commands/response/ratewaifu.js
rename to commands/response/rate-waifu.js
diff --git a/commands/roleplay/falconpunch.js b/commands/roleplay/falcon-punch.js
similarity index 100%
rename from commands/roleplay/falconpunch.js
rename to commands/roleplay/falcon-punch.js
diff --git a/commands/roleplay/fistbump.js b/commands/roleplay/fist-bump.js
similarity index 100%
rename from commands/roleplay/fistbump.js
rename to commands/roleplay/fist-bump.js
diff --git a/commands/roleplay/highfive.js b/commands/roleplay/high-five.js
similarity index 100%
rename from commands/roleplay/highfive.js
rename to commands/roleplay/high-five.js
diff --git a/commands/roleplay/hitwithshovel.js b/commands/roleplay/hit-with-shovel.js
similarity index 100%
rename from commands/roleplay/hitwithshovel.js
rename to commands/roleplay/hit-with-shovel.js
diff --git a/commands/search/botinfo.js b/commands/search/bot-info.js
similarity index 100%
rename from commands/search/botinfo.js
rename to commands/search/bot-info.js
diff --git a/commands/search/yugioh.js b/commands/search/yu-gi-oh.js
similarity index 100%
rename from commands/search/yugioh.js
rename to commands/search/yu-gi-oh.js
diff --git a/commands/settings/clearsetting.js b/commands/settings/clear-setting.js
similarity index 100%
rename from commands/settings/clearsetting.js
rename to commands/settings/clear-setting.js
diff --git a/commands/settings/inviteguard.js b/commands/settings/invite-guard.js
similarity index 100%
rename from commands/settings/inviteguard.js
rename to commands/settings/invite-guard.js
diff --git a/commands/settings/joinrole.js b/commands/settings/join-role.js
similarity index 100%
rename from commands/settings/joinrole.js
rename to commands/settings/join-role.js
diff --git a/commands/settings/memberchannel.js b/commands/settings/member-channel.js
similarity index 100%
rename from commands/settings/memberchannel.js
rename to commands/settings/member-channel.js
diff --git a/commands/settings/membermsg.js b/commands/settings/member-message.js
similarity index 100%
rename from commands/settings/membermsg.js
rename to commands/settings/member-message.js
diff --git a/commands/settings/modchannel.js b/commands/settings/mod-channel.js
similarity index 100%
rename from commands/settings/modchannel.js
rename to commands/settings/mod-channel.js
diff --git a/commands/settings/settinglist.js b/commands/settings/setting-list.js
similarity index 100%
rename from commands/settings/settinglist.js
rename to commands/settings/setting-list.js
diff --git a/commands/settings/singlerole.js b/commands/settings/single-role.js
similarity index 100%
rename from commands/settings/singlerole.js
rename to commands/settings/single-role.js
diff --git a/commands/settings/staffrole.js b/commands/settings/staff-role.js
similarity index 100%
rename from commands/settings/staffrole.js
rename to commands/settings/staff-role.js
diff --git a/commands/textedit/cowsay.js b/commands/textedit/cow-say.js
similarity index 100%
rename from commands/textedit/cowsay.js
rename to commands/textedit/cow-say.js
diff --git a/commands/textedit/upsidedown.js b/commands/textedit/upside-down.js
similarity index 100%
rename from commands/textedit/upsidedown.js
rename to commands/textedit/upside-down.js
diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/user-info.js
similarity index 96%
rename from commands/userinfo/userinfo.js
rename to commands/userinfo/user-info.js
index 1fdd9271..57b6b492 100644
--- a/commands/userinfo/userinfo.js
+++ b/commands/userinfo/user-info.js
@@ -7,8 +7,8 @@ require('moment-duration-format');
module.exports = class UserInfoCommand extends Command {
constructor(client) {
super(client, {
- name: 'user',
- aliases: ['user-info', 'member', 'member-info'],
+ name: 'user-info',
+ aliases: ['user', 'member', 'member-info'],
group: 'userinfo',
memberName: 'user',
description: 'Gives some info on a user.',
diff --git a/commands/util/shardinfo.js b/commands/util/shard-info.js
similarity index 97%
rename from commands/util/shardinfo.js
rename to commands/util/shard-info.js
index 0a1810f2..a9ee34b2 100644
--- a/commands/util/shardinfo.js
+++ b/commands/util/shard-info.js
@@ -7,7 +7,7 @@ module.exports = class ShardInfoCommand extends Command {
constructor(client) {
super(client, {
name: 'shard-info',
- aliases: ['shard'],
+ aliases: ['shard', 'shard-stats'],
group: 'util',
memberName: 'shard-info',
description: 'Gives some bot info for the Shard you specify.',
diff --git a/html/carbonfeat.html b/html/carbonfeat.html
index d8f22638..7ec90941 100644
--- a/html/carbonfeat.html
+++ b/html/carbonfeat.html
@@ -1,17 +1,15 @@
-
+
Features
- Cleverbot!
diff --git a/html/carbonuse.html b/html/carbonuse.html
index d3da8f2d..dd2baaae 100644
--- a/html/carbonuse.html
+++ b/html/carbonuse.html
@@ -1,17 +1,15 @@
-
+
Notes:
- Moderation Commands Require a Channel set with x;modchannel to send Ban/Softban/Kick/Unban/Warn Logs
diff --git a/package.json b/package.json
index 6073a4d5..bdb5904d 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,11 @@
{
"name": "xiaobot",
- "version": "19.13.0",
+ "version": "20.0.0",
"description": "A Discord Bot",
- "main": "shardingmanager.js",
+ "main": "Shard.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
- "start": "node shardingmanager.js"
+ "start": "node Shard.js"
},
"repository": {
"type": "git",
diff --git a/structures/CommandoClient.js b/structures/CommandoClient.js
new file mode 100644
index 00000000..b47ecf75
--- /dev/null
+++ b/structures/CommandoClient.js
@@ -0,0 +1,25 @@
+const { Client } = require('discord.js-commando');
+const Database = require('./PostgreSQL');
+const Cleverbot = require('cleverio');
+const { CLEVS_KEY, CLEVS_USER, CLEVS_NICK } = process.env;
+
+class CommandoClient extends Client {
+ constructor(options) {
+ super(options);
+ this.database = Database.db;
+ this.cleverbot = new Cleverbot({
+ key: CLEVS_KEY,
+ user: CLEVS_USER,
+ nick: CLEVS_NICK
+ });
+
+ Database.start();
+ this.cleverbot.create();
+ }
+
+ get mentionRegex() {
+ return new RegExp(``, 'g');
+ }
+}
+
+module.exports = CommandoClient;