From 5e7a8d17ad40a55cd5f0d1b29f771284b11faa66 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 22 Jun 2017 03:17:03 +0000 Subject: [PATCH] Remove Stuff --- XiaoBot.js | 70 ++------ assets/json/clear-setting.json | 10 -- commands/avatar-edit/3000-years.js | 2 +- commands/avatar-edit/beautiful.js | 2 +- commands/avatar-edit/bob-ross.js | 2 +- commands/avatar-edit/card.js | 2 +- commands/avatar-edit/challenger.js | 2 +- commands/avatar-edit/dexter.js | 2 +- commands/avatar-edit/greyscale.js | 2 +- commands/avatar-edit/invert.js | 2 +- commands/avatar-edit/rip.js | 2 +- commands/avatar-edit/simba.js | 2 +- commands/avatar-edit/steam-card.js | 2 +- commands/avatar-edit/triggered.js | 2 +- commands/avatar-edit/wanted.js | 2 +- commands/moderation/ban.js | 2 +- commands/moderation/kick.js | 2 +- commands/moderation/softban.js | 2 +- commands/moderation/unban.js | 2 +- commands/moderation/warn.js | 2 +- commands/random/star.js | 51 ------ commands/settings/clear-setting.js | 32 ---- commands/settings/invite-guard.js | 19 --- commands/settings/join-role.js | 27 ---- commands/settings/member-channel.js | 27 ---- commands/settings/member-message.js | 47 ------ commands/settings/mod-channel.js | 27 ---- commands/settings/setting-list.js | 33 ---- commands/settings/single-role.js | 27 ---- commands/settings/starboard.js | 27 ---- html/carbonfeat.html | 9 +- html/carbonuse.html | 4 +- html/discordbots.html | 13 +- package.json | 6 +- providers/Sequelize.js | 239 ---------------------------- structures/Command.js | 4 + structures/CommandoClient.js | 13 -- structures/PostgreSQL.js | 23 --- 38 files changed, 40 insertions(+), 704 deletions(-) delete mode 100644 assets/json/clear-setting.json delete mode 100644 commands/random/star.js delete mode 100644 commands/settings/clear-setting.js delete mode 100644 commands/settings/invite-guard.js delete mode 100644 commands/settings/join-role.js delete mode 100644 commands/settings/member-channel.js delete mode 100644 commands/settings/member-message.js delete mode 100644 commands/settings/mod-channel.js delete mode 100644 commands/settings/setting-list.js delete mode 100644 commands/settings/single-role.js delete mode 100644 commands/settings/starboard.js delete mode 100644 providers/Sequelize.js delete mode 100644 structures/CommandoClient.js delete mode 100644 structures/PostgreSQL.js diff --git a/XiaoBot.js b/XiaoBot.js index 62bc919b..6471513a 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -1,6 +1,6 @@ const { TOKEN, OWNER, PREFIX, INVITE } = process.env; const path = require('path'); -const CommandoClient = require('./structures/CommandoClient'); +const { CommandoClient } = require('discord.js-commando'); const client = new CommandoClient({ commandPrefix: PREFIX, owner: OWNER, @@ -8,17 +8,14 @@ const client = new CommandoClient({ disableEveryone: true }); const { carbon, dBots } = require('./structures/Stats'); -const SequelizeProvider = require('./providers/Sequelize'); - -client.setProvider(new SequelizeProvider(client.database)); client.registry .registerDefaultTypes() .registerGroups([ + ['util', 'Utility'], ['user-info', 'User Info'], ['guild-info', 'Server Info'], ['moderation', 'Moderation'], - ['settings', 'Server Settings'], ['random-res', 'Random Response'], ['random-img', 'Random Image'], ['image-edit', 'Image Manipulation'], @@ -30,10 +27,11 @@ client.registry ['random', 'Random/Other'], ['roleplay', 'Roleplay'] ]) - .registerDefaultGroups() .registerDefaultCommands({ help: false, - ping: false + ping: false, + prefix: false, + commandState: false }) .registerCommandsIn(path.join(__dirname, 'commands')); @@ -53,61 +51,16 @@ client.on('warn', console.warn); 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 (!msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) return false; - if (!msg.member.roles.has(role)) return 'single role'; - else return false; -}); - -client.on('message', (msg) => { - if (msg.guild && !msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; - if (/(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) { - if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return; - if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return; - if (!msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) { - msg.say('Could not delete invite, missing permissions.'); - return; - } - msg.delete(); - msg.reply('Invites are prohibited from being posted here.'); - } -}); - -client.on('messageReactionAdd', (reaction, user) => { - if (reaction.emoji.name !== '⭐') return; - const msg = reaction.message; - const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); - if (!channel || !msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return; - if (user.id === msg.author.id) { - reaction.remove(user); - msg.reply('You cannot star your own messages, baka.'); - return; - } - client.registry.resolveCommand('random:star').run(msg, { id: msg.id }, true); -}); - client.on('guildMemberAdd', (member) => { - const role = member.guild.roles.get(member.guild.settings.get('joinRole')); - if (role && member.guild.me.hasPermission('MANAGE_ROLES')) member.addRole(role).catch(() => null); - const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); + const channel = member.guild.channels.find('name', 'member-log'); if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; - const msg = member.guild.settings.get('joinMsg', 'Welcome !') - .replace(/()/gi, member.user.username) - .replace(/()/gi, member.guild.name) - .replace(/()/gi, member); - channel.send(msg); + channel.send(`Welcome ${member.username}!`); }); client.on('guildMemberRemove', (member) => { - const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); + const channel = member.guild.channels.find('name', 'member-log'); if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; - const msg = member.guild.settings.get('leaveMsg', 'Bye ...') - .replace(/()/gi, member.user.username) - .replace(/()/gi, member.guild.name) - .replace(/()/gi, member); - channel.send(msg); + channel.send(`Bye ${member.username}...`); }); client.on('guildCreate', async (guild) => { @@ -126,11 +79,6 @@ client.on('guildDelete', async (guild) => { dBots(count, client.user.id); }); -client.setTimeout(() => { - console.log(`[RESTART] Shard ${client.shard.id} Restarted.`); - process.exit(0); -}, 14400000); - client.login(TOKEN); process.on('unhandledRejection', console.error); diff --git a/assets/json/clear-setting.json b/assets/json/clear-setting.json deleted file mode 100644 index 01c78fa9..00000000 --- a/assets/json/clear-setting.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - "inviteGuard", - "modLog", - "memberLog", - "joinMsg", - "leaveMsg", - "singleRole", - "joinRole", - "starboard" -] diff --git a/commands/avatar-edit/3000-years.js b/commands/avatar-edit/3000-years.js index be7068f4..0787eb77 100644 --- a/commands/avatar-edit/3000-years.js +++ b/commands/avatar-edit/3000-years.js @@ -15,7 +15,7 @@ module.exports = class YearsCommand extends Command { description: 'Draws a user\'s avatar over Pokémon\'s "It\'s been 3000 years" meme.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/beautiful.js b/commands/avatar-edit/beautiful.js index 2f6f7c38..d7236057 100644 --- a/commands/avatar-edit/beautiful.js +++ b/commands/avatar-edit/beautiful.js @@ -15,7 +15,7 @@ module.exports = class BeautifulCommand extends Command { description: 'Draws a user\'s avatar over Gravity Falls\' "Oh, this? This is beautiful." meme.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/bob-ross.js b/commands/avatar-edit/bob-ross.js index e420222e..e3cedf1d 100644 --- a/commands/avatar-edit/bob-ross.js +++ b/commands/avatar-edit/bob-ross.js @@ -15,7 +15,7 @@ module.exports = class BobRossCommand extends Command { description: 'Draws a user\'s avatar over Bob Ross\' canvas.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/card.js b/commands/avatar-edit/card.js index 42a4a2c2..15f033fe 100644 --- a/commands/avatar-edit/card.js +++ b/commands/avatar-edit/card.js @@ -18,7 +18,7 @@ module.exports = class CardCommand extends Command { guildOnly: true, throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/challenger.js b/commands/avatar-edit/challenger.js index 9cbc895c..d15f2f7d 100644 --- a/commands/avatar-edit/challenger.js +++ b/commands/avatar-edit/challenger.js @@ -14,7 +14,7 @@ module.exports = class ChallengerCommand extends Command { description: 'Draws a user\'s avatar over Super Smash Bros.\'s "Challenger Approaching" screen.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/dexter.js b/commands/avatar-edit/dexter.js index 110a674e..fc313afa 100644 --- a/commands/avatar-edit/dexter.js +++ b/commands/avatar-edit/dexter.js @@ -14,7 +14,7 @@ module.exports = class DexterCommand extends Command { description: 'Draws a user\'s avatar over Dexter from Pokémon\'s screen.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/greyscale.js b/commands/avatar-edit/greyscale.js index 0e2e4194..37b1eed4 100644 --- a/commands/avatar-edit/greyscale.js +++ b/commands/avatar-edit/greyscale.js @@ -12,7 +12,7 @@ module.exports = class GreyscaleCommand extends Command { description: 'Draws a user\'s avatar in greyscale.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/invert.js b/commands/avatar-edit/invert.js index 75b12b70..8727bd0b 100644 --- a/commands/avatar-edit/invert.js +++ b/commands/avatar-edit/invert.js @@ -11,7 +11,7 @@ module.exports = class InvertCommand extends Command { description: 'Draws a user\'s avatar inverted.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/rip.js b/commands/avatar-edit/rip.js index 9cc8261f..7493e6ac 100644 --- a/commands/avatar-edit/rip.js +++ b/commands/avatar-edit/rip.js @@ -15,7 +15,7 @@ module.exports = class RIPCommand extends Command { description: 'Draws a user\'s avatar over a gravestone.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/simba.js b/commands/avatar-edit/simba.js index e05afb24..b67acad8 100644 --- a/commands/avatar-edit/simba.js +++ b/commands/avatar-edit/simba.js @@ -14,7 +14,7 @@ module.exports = class SimbaCommand extends Command { description: 'Draws a user\'s avatar over Simba from The Lion King\'s reflection.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/steam-card.js b/commands/avatar-edit/steam-card.js index b8a40c2e..a2472ec6 100644 --- a/commands/avatar-edit/steam-card.js +++ b/commands/avatar-edit/steam-card.js @@ -14,7 +14,7 @@ module.exports = class SteamCardCommand extends Command { description: 'Draws a user\'s avatar over a Steam card.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/triggered.js b/commands/avatar-edit/triggered.js index c7893b7b..64e67e17 100644 --- a/commands/avatar-edit/triggered.js +++ b/commands/avatar-edit/triggered.js @@ -14,7 +14,7 @@ module.exports = class TriggeredCommand extends Command { description: 'Draws a user\'s avatar over a Triggered meme.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/avatar-edit/wanted.js b/commands/avatar-edit/wanted.js index 0fdbf021..983d65ce 100644 --- a/commands/avatar-edit/wanted.js +++ b/commands/avatar-edit/wanted.js @@ -14,7 +14,7 @@ module.exports = class WantedCommand extends Command { description: 'Draws a user\'s avatar over a wanted poster.', throttling: { usages: 1, - duration: 15 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], args: [ diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 23bb7587..c15319d1 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -33,7 +33,7 @@ module.exports = class BanCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); + const modlogs = msg.guild.channels.find('name', 'mod-log'); const { member, reason } = args; if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index aa7acb67..f7313025 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -33,7 +33,7 @@ module.exports = class KickCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); + const modlogs = msg.guild.channels.find('name', 'mod-log'); const { member, reason } = args; if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?'); await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`); diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 91bd0e21..70ab1acb 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -33,7 +33,7 @@ module.exports = class SoftbanCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); + const modlogs = msg.guild.channels.find('name', 'mod-log'); const { member, reason } = args; if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`); diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index abb1b0a6..e5fcca6c 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -33,7 +33,7 @@ module.exports = class UnbanCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); + const modlogs = msg.guild.channels.find('name', 'mod-log'); const { id, reason } = args; const bans = await msg.guild.fetchBans(); if (!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.'); diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index e400c640..b65c11de 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -32,7 +32,7 @@ module.exports = class WarnCommand extends Command { } async run(msg, args) { - const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); + const modlogs = msg.guild.channels.find('name', 'mod-log'); const { member, reason } = args; await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`); const msgs = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, { diff --git a/commands/random/star.js b/commands/random/star.js deleted file mode 100644 index f7222c64..00000000 --- a/commands/random/star.js +++ /dev/null @@ -1,51 +0,0 @@ -const Command = require('../../structures/Command'); -const { RichEmbed } = require('discord.js'); -const { stripIndents } = require('common-tags'); -const moment = require('moment'); - -module.exports = class StarCommand extends Command { - constructor(client) { - super(client, { - name: 'star', - group: 'random', - memberName: 'star', - description: 'Stars a message, sending it to the starboard.', - args: [ - { - key: 'id', - prompt: 'What is the ID of the message you wish to star?', - type: 'string' - } - ] - }); - - this.starred = []; - } - - async run(msg, args, reaction) { - const { id } = args; - const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); - if (!channel || this.starred.includes(id)) return null; - const message = await msg.channel.fetchMessage(id); - if (!reaction && msg.author.id === message.author.id) return msg.reply('You cannot star your own messages.'); - this.starred.push(id); - if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) { - return msg.say('Could not send the message to the starboard.'); - } else if (channel.permissionsFor(this.client.user).has('EMBED_LINKS')) { - const embed = new RichEmbed() - .setColor(0xFFFF00) - .setAuthor(message.author.tag, message.author.displayAvatarURL) - .setDescription(message.content) - .setImage(message.attachments.first() ? message.attachments.first().url : null) - .setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')); - return channel.send({ embed }); - } else { - return msg.say(stripIndents` - **Author:** ${message.author.tag} - **Content:** ${message.content} - **Date:** ${moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')} - ${message.attachments.first() ? `**Image:** ${message.attachments.first().url}` : ''} - `); - } - } -}; diff --git a/commands/settings/clear-setting.js b/commands/settings/clear-setting.js deleted file mode 100644 index 42e11f55..00000000 --- a/commands/settings/clear-setting.js +++ /dev/null @@ -1,32 +0,0 @@ -const Command = require('../../structures/Command'); -const settings = require('../../assets/json/clear-setting'); - -module.exports = class ClearSettingCommand extends Command { - constructor(client) { - super(client, { - name: 'clear-setting', - group: 'settings', - memberName: 'clear-setting', - description: 'Removes a custom setting from your server.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'setting', - prompt: 'What setting do you want to clear?', - type: 'string', - validate: (setting) => { - if (settings.includes(setting)) return true; - else return `Please enter one of the following: ${settings.join(', ')}`; - } - } - ] - }); - } - - run(msg, args) { - const { setting } = args; - msg.guild.settings.remove(setting); - return msg.say(`${setting} has been removed from your server settings.`); - } -}; diff --git a/commands/settings/invite-guard.js b/commands/settings/invite-guard.js deleted file mode 100644 index 6d3debef..00000000 --- a/commands/settings/invite-guard.js +++ /dev/null @@ -1,19 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class InviteGuardCommand extends Command { - constructor(client) { - super(client, { - name: 'invite-guard', - group: 'settings', - memberName: 'invite-guard', - description: 'Turns on auto-deletion of invites.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'] - }); - } - - run(msg) { - msg.guild.settings.set('inviteGuard', true); - return msg.say('Invite Guard is now active.'); - } -}; diff --git a/commands/settings/join-role.js b/commands/settings/join-role.js deleted file mode 100644 index 828e0c77..00000000 --- a/commands/settings/join-role.js +++ /dev/null @@ -1,27 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class JoinRoleCommand extends Command { - constructor(client) { - super(client, { - name: 'join-role', - group: 'settings', - memberName: 'join-role', - description: 'Sets a role that new members are automatically joined to.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'role', - prompt: 'What role should new members be joined to?', - type: 'role' - } - ] - }); - } - - run(msg, args) { - const { role } = args; - msg.guild.settings.set('joinRole', role.id); - return msg.say(`Join Role set to ${role.name}.`); - } -}; diff --git a/commands/settings/member-channel.js b/commands/settings/member-channel.js deleted file mode 100644 index c5728755..00000000 --- a/commands/settings/member-channel.js +++ /dev/null @@ -1,27 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class MemberLogCommand extends Command { - constructor(client) { - super(client, { - name: 'member-channel', - group: 'settings', - memberName: 'member-channel', - description: 'Sets a channel for member join/leave logs to be sent.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'channel', - prompt: 'What is the channel you want to send logs to?', - type: 'channel' - } - ] - }); - } - - run(msg, args) { - const { channel } = args; - msg.guild.settings.set('memberLog', channel.id); - return msg.say(`Member Log channel set to ${channel.name}.`); - } -}; diff --git a/commands/settings/member-message.js b/commands/settings/member-message.js deleted file mode 100644 index 4d30ce76..00000000 --- a/commands/settings/member-message.js +++ /dev/null @@ -1,47 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class MemberMsgCommand extends Command { - constructor(client) { - super(client, { - name: 'member-message', - aliases: ['member-msg'], - group: 'settings', - memberName: 'member-message', - description: 'Sets the message for either join/leave logs to use.', - details: '**Placeholders:** : Username, : Server Name, : A Mention of the User', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'type', - prompt: 'Which message would you like to change? Please enter either `joinMsg` or `leaveMsg`.', - type: 'string', - validate: (type) => { - if (['joinMsg', 'leaveMsg'].includes(type)) return true; - else return 'Please enter either `joinMsg` or `leaveMsg`.'; - } - }, - { - key: 'message', - prompt: 'What should be sent to the channel? Use , , and as placeholders.', - type: 'string', - validate: (message) => { - if (message.length < 150) return true; - else return 'Invalid Message. Message must be under 150 characters.'; - } - } - ] - }); - } - - run(msg, args) { - const { type, message } = args; - if (type === 'joinMsg') { - msg.guild.settings.set('joinMsg', message); - return msg.say(`Join Message set to "${message}".`); - } else { - msg.guild.settings.set('leaveMsg', message); - return msg.say(`Leave Message set to "${message}".`); - } - } -}; diff --git a/commands/settings/mod-channel.js b/commands/settings/mod-channel.js deleted file mode 100644 index 2bc21a8a..00000000 --- a/commands/settings/mod-channel.js +++ /dev/null @@ -1,27 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class ModChannelCommand extends Command { - constructor(client) { - super(client, { - name: 'mod-channel', - group: 'settings', - memberName: 'mod-channel', - description: 'Sets a channel for mod logs to be sent.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'channel', - prompt: 'What is the channel you want to send logs to?', - type: 'channel' - } - ] - }); - } - - run(msg, args) { - const { channel } = args; - msg.guild.settings.set('modLog', channel.id); - return msg.say(`Mod Log channel set to ${channel.name}.`); - } -}; diff --git a/commands/settings/setting-list.js b/commands/settings/setting-list.js deleted file mode 100644 index a3010ad0..00000000 --- a/commands/settings/setting-list.js +++ /dev/null @@ -1,33 +0,0 @@ -const Command = require('../../structures/Command'); -const { stripIndents } = require('common-tags'); - -module.exports = class SettingListCommand extends Command { - constructor(client) { - super(client, { - name: 'setting-list', - group: 'settings', - memberName: 'setting-list', - description: 'Shows a list of current guild settings.', - guildOnly: true - }); - } - - run(msg) { - const modLog = msg.guild.channels.get(msg.guild.settings.get('modLog')); - const memberLog = msg.guild.channels.get(msg.guild.settings.get('memberLog')); - const singleRole = msg.guild.roles.get(msg.guild.settings.get('singleRole')); - const joinRole = msg.guild.roles.get(msg.guild.settings.get('joinRole')); - const starboard = msg.guild.channels.get(msg.guild.settings.get('starboard')); - return msg.say(stripIndents` - **Prefix:** ${msg.guild.commandPrefix} - **Invite Guard:** ${msg.guild.settings.get('inviteGuard', false)} - **Mod Channel:** ${modLog ? modLog.name : 'None'} - **Starboard:** ${starboard ? starboard.name : 'None'} - **Join Role:** ${joinRole ? joinRole.name : 'None'} - **Member Channel:** ${memberLog ? memberLog.name : 'None'} - **Join Message:** ${msg.guild.settings.get('joinMsg', 'Welcome ! (Default)')} - **Leave Message:** ${msg.guild.settings.get('leaveMsg', 'Bye ... (Default)')} - **Single Role:** ${singleRole ? singleRole.name : 'None'} - `); - } -}; diff --git a/commands/settings/single-role.js b/commands/settings/single-role.js deleted file mode 100644 index 0e5e8a6f..00000000 --- a/commands/settings/single-role.js +++ /dev/null @@ -1,27 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class SingleRoleCommand extends Command { - constructor(client) { - super(client, { - name: 'single-role', - group: 'settings', - memberName: 'single-role', - description: 'Sets a single role that is able to use commands.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'role', - prompt: 'What role should be able to use commands?', - type: 'role' - } - ] - }); - } - - run(msg, args) { - const { role } = args; - msg.guild.settings.set('singleRole', role.id); - return msg.say(`Single role mode has been enabled with the role ${role.name}.`); - } -}; diff --git a/commands/settings/starboard.js b/commands/settings/starboard.js deleted file mode 100644 index 778ea31f..00000000 --- a/commands/settings/starboard.js +++ /dev/null @@ -1,27 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class StarboardCommand extends Command { - constructor(client) { - super(client, { - name: 'starboard', - group: 'settings', - memberName: 'starboard', - description: 'Sets a channel for the starboard.', - guildOnly: true, - userPermissions: ['ADMINISTRATOR'], - args: [ - { - key: 'channel', - prompt: 'What is the channel you want to set as the starboard?', - type: 'channel' - } - ] - }); - } - - run(msg, args) { - const { channel } = args; - msg.guild.settings.set('starboard', channel.id); - return msg.say(`Starboard set to ${channel.name}.`); - } -}; diff --git a/html/carbonfeat.html b/html/carbonfeat.html index 07e838c7..08f1b025 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -20,14 +20,13 @@
  • Minecraft Achievement Generation!
  • Meme Generation!
  • Pokémon Fusion!
  • -
  • Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Customizable Logging!
  • +
  • Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Logging!
  • Currency and Temperature Conversion!
  • Math Calculator!
  • Cleverbot!
  • Tons of Secret Easter Eggs to discover!
  • Horoscopes!
  • LMGTFY Link Generation!
  • -
  • Starboard!
  • Strawpoll Generation!
  • Events that Happened today in history!
  • Would you rather questions!
  • @@ -64,11 +63,7 @@
  • Translate Text to almost 100 languages!
  • Binary, Morse, Pirate, and Temmie Translators!
  • Cowsay, Embed, Reverse, Upside Down, and Zalgo Text!
  • -
  • Customizable Prefix!
  • -
  • Protect your server against Invite Advertising!
  • -
  • Add a role to a user on join!
  • -
  • Member Join/Leave Logging to a Customizable Channel, with a Customizable Message!
  • -
  • Optional "Single Role Mode" where only one role can use the bot's commands!
  • +
  • Member Join/Leave Logging!
  • And so so so much more!
  • diff --git a/html/carbonuse.html b/html/carbonuse.html index 011b2885..7cbd7f4d 100644 --- a/html/carbonuse.html +++ b/html/carbonuse.html @@ -12,8 +12,8 @@

    Notes

      -
    1. Moderation commands require a channel set with x;modchannel to send Ban/Kick/Softban/Unban/Warn logs.
    2. -
    3. To use member join/leave logging, set a channel with x;memberchannel. A custom message can be set with x;membermsg.
    4. +
    5. Moderation commands require a channel named mod-log to send Ban/Kick/Softban/Unban/Warn logs.
    6. +
    7. To use member join/leave logging, create a channel named member-log.
    8. Use x;help to view a command list
    9. Visit my home server for more support, or for updates, or if you just want to hang out.
    diff --git a/html/discordbots.html b/html/discordbots.html index 21e124b8..81c581da 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -17,14 +17,13 @@
  • Minecraft Achievement Generation!
  • Meme Generation!
  • Pokémon Fusion!
  • -
  • Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Customizable Logging!
  • +
  • Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Logging!
  • Currency and Temperature Conversion!
  • Math Calculator!
  • Cleverbot!
  • Tons of Secret Easter Eggs to discover!
  • Horoscopes!
  • LMGTFY Link Generation!
  • -
  • Starboard!
  • Strawpoll Generation!
  • Events that Happened today in history!
  • Would you rather questions!
  • @@ -61,18 +60,14 @@
  • Translate Text to almost 100 languages!
  • Binary, Morse, Pirate, and Temmie Translators!
  • Cowsay, Embed, Reverse, Upside Down, and Zalgo Text!
  • -
  • Customizable Prefix!
  • -
  • Protect your server against Invite Advertising!
  • -
  • Add a role to a user on join!
  • -
  • Member Join/Leave Logging to a Customizable Channel, with a Customizable Message!
  • -
  • Optional "Single Role Mode" where only one role can use the bot's commands!
  • +
  • Member Join/Leave Logging!
  • And so so so much more!
  • Notes

      -
    1. Moderation commands require a channel set with x;modchannel to send Ban/Kick/Softban/Unban/Warn logs.
    2. -
    3. To use member join/leave logging, set a channel with x;memberchannel. A custom message can be set with x;membermsg.
    4. +
    5. Moderation commands require a channel named mod-log to send Ban/Kick/Softban/Unban/Warn logs.
    6. +
    7. To use member join/leave logging, create a channel named member-log.
    8. Use x;help to view a command list
    9. Visit my home server for more support, or for updates, or if you just want to hang out.
    diff --git a/package.json b/package.json index fe28df71..c6f4e13d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "24.0.0", + "version": "25.0.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": { @@ -20,8 +20,6 @@ "discord-bot", "discord-js", "discord-js-commando", - "postgres", - "postgresql", "cleverbot" ], "author": "dragonfire535 ", @@ -45,8 +43,6 @@ "mathjs": "^3.13.3", "moment": "^2.18.1", "moment-duration-format": "^1.3.0", - "pg": "^6.2.4", - "sequelize": "^4.1.0", "snekfetch": "^3.1.11", "tsubaki": "^1.1.1", "xml2js": "^0.4.17", diff --git a/providers/Sequelize.js b/providers/Sequelize.js deleted file mode 100644 index dc09c16f..00000000 --- a/providers/Sequelize.js +++ /dev/null @@ -1,239 +0,0 @@ -const { SettingProvider } = require('discord.js-commando'); -const Sequelize = require('sequelize'); - -/** - * Uses an PostgreSQL database to store settings with guilds - * @extends {SettingProvider} - */ -class SequelizeProvider extends SettingProvider { - /** - * @external PostgreSQLDatabase - * @see {@link https://www.npmjs.com/package/sequelize} - */ - - /** - * @param {SQLDatabase} db - Database for the provider - */ - constructor(db) { - super(); - - /** - * Database that will be used for storing/retrieving settings - * @type {SQLDatabase} - */ - this.db = db; - - /** - * Client that the provider is for (set once the client is ready) - * @name SequelizeProvider#client - * @type {CommandoClient} - * @readonly - */ - Object.defineProperty(this, 'client', { value: null, writable: true }); - - /** - * Settings cached in memory, mapped by guild ID (or 'global') - * @type {Map} - * @private - */ - this.settings = new Map(); - - /** - * Listeners on the Client, mapped by the event name - * @type {Map} - * @private - */ - this.listeners = new Map(); - - /** - * Sequelize Model Object - * @type {SequelizeModel} - * @private - */ - this.model = this.db.define('settings', { - guild: { - type: Sequelize.STRING, - allowNull: false, - unique: true, - primaryKey: true - }, - settings: { type: Sequelize.TEXT } - }); - - /** - * @external SequelizeModel - * @see {@link http://docs.sequelizejs.com/en/latest/api/model/} - */ - } - - async init(client) { - this.client = client; - await this.db.sync(); - - // Load all settings - const rows = await this.model.findAll(); - for (const row of rows) { - let settings; - try { - settings = JSON.parse(row.dataValues.settings); - } catch (err) { - client.emit('warn', `SequelizeProvider couldn't parse the settings stored for guild ${row.dataValues.guild}.`); // eslint-disable-line max-len - continue; - } - - const guild = row.dataValues.guild !== '0' ? row.dataValues.guild : 'global'; - - this.settings.set(guild, settings); - if (guild !== 'global' && !client.guilds.has(row.dataValues.guild)) continue; - this.setupGuild(guild, settings); - } - - // Listen for changes - this.listeners - .set('commandPrefixChange', (guild, prefix) => this.set(guild, 'prefix', prefix)) - .set('commandStatusChange', (guild, command, enabled) => this.set(guild, `cmd-${command.name}`, enabled)) - .set('groupStatusChange', (guild, group, enabled) => this.set(guild, `grp-${group.id}`, enabled)) - .set('guildCreate', (guild) => { - const settings = this.settings.get(guild.id); - if (!settings) return; - this.setupGuild(guild.id, settings); - }) - .set('commandRegister', (command) => { - for (const [guild, settings] of this.settings) { - if (guild !== 'global' && !client.guilds.has(guild)) continue; - this.setupGuildCommand(client.guilds.get(guild), command, settings); - } - }) - .set('groupRegister', (group) => { - for (const [guild, settings] of this.settings) { - if (guild !== 'global' && !client.guilds.has(guild)) continue; - this.setupGuildGroup(client.guilds.get(guild), group, settings); - } - }); - for (const [event, listener] of this.listeners) client.on(event, listener); - } - - destroy() { - // Remove all listeners from the client - for (const [event, listener] of this.listeners) this.client.removeListener(event, listener); - this.listeners.clear(); - } - - get(guild, key, defVal) { - const settings = this.settings.get(this.constructor.getGuildID(guild)); - return settings ? typeof settings[key] !== 'undefined' ? settings[key] : defVal : defVal; - } - - async set(guild, key, val) { - guild = this.constructor.getGuildID(guild); - let settings = this.settings.get(guild); - if (!settings) { - settings = {}; - this.settings.set(guild, settings); - } - - settings[key] = val; - await this.model.upsert( - { guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, - { where: { guild: guild !== 'global' ? guild : '0' } } - ); - if (guild === 'global') this.updateOtherShards(key, val); - return val; - } - - async remove(guild, key) { - guild = this.constructor.getGuildID(guild); - const settings = this.settings.get(guild); - if (!settings || typeof settings[key] === 'undefined') return undefined; - - const val = settings[key]; - settings[key] = undefined; - await this.model.upsert( - { guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, - { where: { guild: guild !== 'global' ? guild : '0' } } - ); - if (guild === 'global') this.updateOtherShards(key, undefined); - return val; - } - - async clear(guild) { - guild = this.constructor.getGuildID(guild); - if (!this.settings.has(guild)) return; - this.settings.delete(guild); - await this.model.destroy({ where: { guild: guild !== 'global' ? guild : '0' } }); - } - - /** - * Loads all settings for a guild - * @param {string} guild - Guild ID to load the settings of (or 'global') - * @param {Object} settings - Settings to load - * @private - */ - setupGuild(guild, settings) { - if (typeof guild !== 'string') throw new TypeError('The guild must be a guild ID or "global".'); - guild = this.client.guilds.get(guild) || null; - - // Load the command prefix - if (typeof settings.prefix !== 'undefined') { - if (guild) guild._commandPrefix = settings.prefix; - else this.client._commandPrefix = settings.prefix; - } - - // Load all command/group statuses - for (const command of this.client.registry.commands.values()) this.setupGuildCommand(guild, command, settings); - for (const group of this.client.registry.groups.values()) this.setupGuildGroup(guild, group, settings); - } - - /** - * Sets up a command's status in a guild from the guild's settings - * @param {?Guild} guild - Guild to set the status in - * @param {Command} command - Command to set the status of - * @param {Object} settings - Settings of the guild - * @private - */ - setupGuildCommand(guild, command, settings) { - if (typeof settings[`cmd-${command.name}`] === 'undefined') return; - if (guild) { - if (!guild._commandsEnabled) guild._commandsEnabled = {}; - guild._commandsEnabled[command.name] = settings[`cmd-${command.name}`]; - } else { - command._globalEnabled = settings[`cmd-${command.name}`]; - } - } - - /** - * Sets up a group's status in a guild from the guild's settings - * @param {?Guild} guild - Guild to set the status in - * @param {CommandGroup} group - Group to set the status of - * @param {Object} settings - Settings of the guild - * @private - */ - setupGuildGroup(guild, group, settings) { - if (typeof settings[`grp-${group.id}`] === 'undefined') return; - if (guild) { - if (!guild._groupsEnabled) guild._groupsEnabled = {}; - guild._groupsEnabled[group.id] = settings[`grp-${group.id}`]; - } else { - group._globalEnabled = settings[`grp-${group.id}`]; - } - } - - /** - * Updates a global setting on all other shards if using the {@link ShardingManager}. - * @param {string} key - Key of the setting to update - * @param {*} val - Value of the setting - * @private - */ - updateOtherShards(key, val) { - if (!this.client.shard) return; - key = JSON.stringify(key); - val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined'; - this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id} && this.provider && this.provider.settings) { - this.provider.settings.global[${key}] = ${val}; - } - `); - } -} - -module.exports = SequelizeProvider; diff --git a/structures/Command.js b/structures/Command.js index 5b4e539d..d40d3598 100644 --- a/structures/Command.js +++ b/structures/Command.js @@ -8,6 +8,10 @@ class XiaoCommand extends Command { this.nsfw = info.nsfw; this.clientPermissions = info.clientPermissions; this.userPermissions = info.userPermissions; + this.throttling = { + usages: 1, + duration: 2 + }; } hasPermission(msg) { diff --git a/structures/CommandoClient.js b/structures/CommandoClient.js deleted file mode 100644 index e77e3e97..00000000 --- a/structures/CommandoClient.js +++ /dev/null @@ -1,13 +0,0 @@ -const { Client } = require('discord.js-commando'); -const Database = require('./PostgreSQL'); - -class CommandoClient extends Client { - constructor(options) { - super(options); - - this.database = Database.db; - Database.start(); - } -} - -module.exports = CommandoClient; diff --git a/structures/PostgreSQL.js b/structures/PostgreSQL.js deleted file mode 100644 index 9b6a6f68..00000000 --- a/structures/PostgreSQL.js +++ /dev/null @@ -1,23 +0,0 @@ -const Sequelize = require('sequelize'); -const { DATABASE_URL } = process.env; -const database = new Sequelize(DATABASE_URL, { logging: false }); - -class Database { - static get db() { - return database; - } - - static start() { - database.authenticate() - .then(() => console.log('[DATABASE] Connection has been established successfully.')) - .then(() => console.log('[DATABASE] Synchronizing...')) - .then(() => database.sync() - .then(() => console.log('[DATABASE] Synchronizing complete!')) - .catch((err) => console.error(`[DATABASE] Error synchronizing: ${err}`)) - ) - .then(() => console.log('[DATABASE] Ready!')) - .catch((err) => console.error(`[DATABASE] Unable to connect: ${err}`)); - } -} - -module.exports = Database;