From c0990a0b23e80989c421acd8e2f070957ac8d51a Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 8 Jul 2018 15:33:45 +0000 Subject: [PATCH] Remove Tag and Role Management (no one uses and they suck) --- README.md | 22 ++---------- commands/role-manage/add-open-role.js | 31 ---------------- commands/role-manage/fix-open-roles.js | 30 ---------------- commands/role-manage/remove-open-role.js | 32 ----------------- commands/role-manage/role-list.js | 24 ------------- commands/role-manage/subscribe.js | 30 ---------------- commands/role-manage/unsubscribe.js | 30 ---------------- commands/tags/add.js | 42 ---------------------- commands/tags/edit.js | 40 --------------------- commands/tags/info.js | 45 ------------------------ commands/tags/remove.js | 34 ------------------ commands/tags/source.js | 29 --------------- commands/tags/view.js | 30 ---------------- models/Tag.js | 23 ------------ package.json | 2 +- 15 files changed, 3 insertions(+), 441 deletions(-) delete mode 100644 commands/role-manage/add-open-role.js delete mode 100644 commands/role-manage/fix-open-roles.js delete mode 100644 commands/role-manage/remove-open-role.js delete mode 100644 commands/role-manage/role-list.js delete mode 100644 commands/role-manage/subscribe.js delete mode 100644 commands/role-manage/unsubscribe.js delete mode 100644 commands/tags/add.js delete mode 100644 commands/tags/edit.js delete mode 100644 commands/tags/info.js delete mode 100644 commands/tags/remove.js delete mode 100644 commands/tags/source.js delete mode 100644 commands/tags/view.js delete mode 100644 models/Tag.js diff --git a/README.md b/README.md index 4f848499..54d966c6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Xiao is a Discord bot coded in JavaScript with [discord.js](https://discord.js.org/) using the -[Commando](https://github.com/discordjs/Commando) command framework. With over +[Commando](https://github.com/discordjs/Commando) command framework. With nearly 300 commands, she is one of the most feature-filled bots out there. ## Invite @@ -15,7 +15,7 @@ You can invite the bot to your server using Be sure to also join the [home server](https://discord.gg/sbMe32W) for information and support. -## Commands (302) +## Commands (290) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -322,24 +322,6 @@ information and support. * **roman-numeral**: Converts a number to roman numerals. * **units**: Converts units to/from other units. -### Server Tags: - -* **tag-add**: Adds a tag for this server. -* **tag-edit**: Edits a tag in this server. -* **tag-info**: Responds with detailed information on a tag in this server. -* **tag-remove**: Removes a tag from this server. -* **tag-source**: Responds with the base markdown of a tag in this server. -* **tag-view**: Responds with a tag in this server. - -### Role Management: - -* **add-open-role**: Sets a role as open. -* **fix-open-roles**: Removes no longer existent roles from the open roles lists. -* **remove-open-role**: Remove a role from the open roles. -* **role-list**: Responds with all available roles to join. -* **subscribe**: Subscribes you to the specified role. -* **unsubscribe**: Unsubscribes you from the specified role. - ### Portal Messages: * **add-portal-channel**: Sets a channel to be a portal channel. diff --git a/commands/role-manage/add-open-role.js b/commands/role-manage/add-open-role.js deleted file mode 100644 index e0b8fc51..00000000 --- a/commands/role-manage/add-open-role.js +++ /dev/null @@ -1,31 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class AddOpenRoleCommand extends Command { - constructor(client) { - super(client, { - name: 'add-open-role', - aliases: ['set-open-role', 'open-role'], - group: 'role-manage', - memberName: 'add-open-role', - description: 'Sets a role as open.', - guildOnly: true, - userPermissions: ['MANAGE_ROLES'], - args: [ - { - key: 'role', - prompt: 'What role do you want to open?', - type: 'role' - } - ] - }); - } - - run(msg, { role }) { - if (role.id === msg.guild.defaultRole.id) return msg.reply('The everyone role is already open!'); - const roles = msg.guild.settings.get('openRoles', []); - if (roles.includes(role.id)) return msg.reply(`${role.name} is already open!`); - roles.push(role.id); - msg.guild.settings.set('openRoles', roles); - return msg.say(`${role.name} is now open!`); - } -}; diff --git a/commands/role-manage/fix-open-roles.js b/commands/role-manage/fix-open-roles.js deleted file mode 100644 index 2129e491..00000000 --- a/commands/role-manage/fix-open-roles.js +++ /dev/null @@ -1,30 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class FixOpenRolesCommand extends Command { - constructor(client) { - super(client, { - name: 'fix-open-roles', - aliases: ['fix-roles'], - group: 'role-manage', - memberName: 'fix-open-roles', - description: 'Removes no longer existent roles from the open roles lists.', - ownerOnly: true - }); - } - - run(msg) { - let count = 0; - for (const guild of this.client.guilds.values()) { - const roles = guild.settings.get('openRoles', []); - if (!roles.length) continue; - for (const role of roles) { - if (guild.roles.has(role)) continue; - roles.splice(roles.indexOf(role), 1); - count++; - } - if (!roles.length) guild.settings.remove('openRoles'); - else guild.settings.set('openRoles', roles); - } - return msg.say(`Cleared **${count}** roles from the open roles lists.`); - } -}; diff --git a/commands/role-manage/remove-open-role.js b/commands/role-manage/remove-open-role.js deleted file mode 100644 index 45eaabaa..00000000 --- a/commands/role-manage/remove-open-role.js +++ /dev/null @@ -1,32 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class RemoveOpenRoleCommand extends Command { - constructor(client) { - super(client, { - name: 'remove-open-role', - aliases: ['delete-open-role', 'close-role'], - group: 'role-manage', - memberName: 'remove-open-role', - description: 'Remove a role from the open roles.', - guildOnly: true, - userPermissions: ['MANAGE_ROLES'], - args: [ - { - key: 'role', - prompt: 'What role do you want to close?', - type: 'role' - } - ] - }); - } - - run(msg, { role }) { - if (role.id === msg.guild.defaultRole.id) return msg.reply('The everyone role cannot be closed!'); - const roles = msg.guild.settings.get('openRoles', []); - if (!roles.includes(role.id)) return msg.reply(`${role.name} is not open!`); - roles.splice(roles.indexOf(role.id), 1); - if (!roles.length) msg.guild.settings.remove('openRoles'); - else msg.guild.settings.set('openRoles', roles); - return msg.say(`${role.name} is now closed...`); - } -}; diff --git a/commands/role-manage/role-list.js b/commands/role-manage/role-list.js deleted file mode 100644 index e048c124..00000000 --- a/commands/role-manage/role-list.js +++ /dev/null @@ -1,24 +0,0 @@ -const Command = require('../../structures/Command'); -const { stripIndents } = require('common-tags'); - -module.exports = class RoleListCommand extends Command { - constructor(client) { - super(client, { - name: 'role-list', - aliases: ['roles', 'open-roles'], - group: 'role-manage', - memberName: 'role-list', - description: 'Responds with all available roles to join.', - guildOnly: true - }); - } - - run(msg) { - const roles = msg.guild.settings.get('openRoles', []); - if (!roles.length) return msg.say('This server has no open roles...'); - return msg.say(stripIndents` - **Roles available in ${msg.guild.name}**: - ${msg.guild.roles.filter(role => roles.includes(role.id)).map(role => role.name).join('\n')} - `); - } -}; diff --git a/commands/role-manage/subscribe.js b/commands/role-manage/subscribe.js deleted file mode 100644 index 212da62e..00000000 --- a/commands/role-manage/subscribe.js +++ /dev/null @@ -1,30 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class SubscribeCommand extends Command { - constructor(client) { - super(client, { - name: 'subscribe', - group: 'role-manage', - memberName: 'subscribe', - description: 'Subscribes you to the specified role.', - guildOnly: true, - clientPermissions: ['MANAGE_ROLES'], - args: [ - { - key: 'role', - prompt: 'What role do you want to subscribe to?', - type: 'role' - } - ] - }); - } - - async run(msg, { role }) { - const roles = msg.guild.settings.get('openRoles', []); - if (!roles.includes(role.id)) return msg.reply('This role is not open!'); - if (!role.editable) return msg.reply('I do not have permission to manage this role!'); - if (msg.member.roles.has(role.id)) return msg.reply('You are already a member of this role!'); - await msg.member.roles.add(role); - return msg.say(`You were added to **${role.name}**!`); - } -}; diff --git a/commands/role-manage/unsubscribe.js b/commands/role-manage/unsubscribe.js deleted file mode 100644 index 37a277b9..00000000 --- a/commands/role-manage/unsubscribe.js +++ /dev/null @@ -1,30 +0,0 @@ -const Command = require('../../structures/Command'); - -module.exports = class UnsubscribeCommand extends Command { - constructor(client) { - super(client, { - name: 'unsubscribe', - group: 'role-manage', - memberName: 'unsubscribe', - description: 'Unsubscribes you from the specified role.', - guildOnly: true, - clientPermissions: ['MANAGE_ROLES'], - args: [ - { - key: 'role', - prompt: 'What role do you want to unsubscribe from?', - type: 'role' - } - ] - }); - } - - async run(msg, { role }) { - const roles = msg.guild.settings.get('openRoles', []); - if (!roles.includes(role.id)) return msg.reply('This role is not open!'); - if (!role.editable) return msg.reply('I do not have permission to manage this role!'); - if (!msg.member.roles.has(role.id)) return msg.reply('You are not a member of this role!'); - await msg.member.roles.remove(role); - return msg.say(`You were removed from **${role.name}**...`); - } -}; diff --git a/commands/tags/add.js b/commands/tags/add.js deleted file mode 100644 index 0e4c4e97..00000000 --- a/commands/tags/add.js +++ /dev/null @@ -1,42 +0,0 @@ -const Command = require('../../structures/Command'); -const Tag = require('../../models/Tag'); - -module.exports = class TagAddCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-add', - aliases: ['add-tag'], - group: 'tags', - memberName: 'add', - description: 'Adds a tag for this server.', - guildOnly: true, - args: [ - { - key: 'name', - prompt: 'What should the name of the tag be?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - }, - { - key: 'text', - prompt: 'What should the content of the tag be?', - type: 'string', - max: 1000 - } - ] - }); - } - - async run(msg, { name, text }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (tag) return msg.reply(`A tag with the name **${name}** already exists.`); - await Tag.create({ - userID: msg.author.id, - guildID: msg.guild.id, - name, - text - }); - return msg.reply(`Added **${name}**.`); - } -}; diff --git a/commands/tags/edit.js b/commands/tags/edit.js deleted file mode 100644 index f3d6466a..00000000 --- a/commands/tags/edit.js +++ /dev/null @@ -1,40 +0,0 @@ -const Command = require('../../structures/Command'); -const Tag = require('../../models/Tag'); - -module.exports = class TagEditCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-edit', - aliases: ['edit-tag'], - group: 'tags', - memberName: 'edit', - description: 'Edits a tag in this server.', - guildOnly: true, - args: [ - { - key: 'name', - prompt: 'What is the name of the tag you want to edit?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - }, - { - key: 'text', - prompt: 'What should the new content of the tag be?', - type: 'string', - max: 1000 - } - ] - }); - } - - async run(msg, { name, text }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); - if (!msg.channel.permissionsFor(msg.author).has('MANAGE_MESSAGES') && tag.userID !== msg.author.id) { - return msg.reply('You can only edit your own tags.'); - } - await Tag.update({ text }, { where: { name, guildID: msg.guild.id } }); - return msg.reply(`Edited **${name}**.`); - } -}; diff --git a/commands/tags/info.js b/commands/tags/info.js deleted file mode 100644 index 920f692c..00000000 --- a/commands/tags/info.js +++ /dev/null @@ -1,45 +0,0 @@ -const Command = require('../../structures/Command'); -const { MessageEmbed } = require('discord.js'); -const Tag = require('../../models/Tag'); - -module.exports = class TagInfoCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-info', - group: 'tags', - memberName: 'info', - description: 'Responds with detailed information on a tag in this server.', - guildOnly: true, - clientPermissions: ['EMBED_LINKS'], - args: [ - { - key: 'name', - prompt: 'What is the name of the tag you want to get information on?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - } - ] - }); - } - - async run(msg, { name }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); - let author; - try { - const authorUser = await this.client.users.fetch(tag.userID); - author = authorUser.tag; - } catch (err) { - author = '???'; - } - const embed = new MessageEmbed() - .setColor(0x00AE86) - .setThumbnail(msg.guild.iconURL()) - .addField('❯ Name', tag.name, true) - .addField('❯ Author', author, true) - .addField('❯ Created On', new Date(tag.createdAt).toDateString(), true) - .addField('❯ Modified On', new Date(tag.updatedAt).toDateString(), true); - return msg.embed(embed); - } -}; diff --git a/commands/tags/remove.js b/commands/tags/remove.js deleted file mode 100644 index be272a93..00000000 --- a/commands/tags/remove.js +++ /dev/null @@ -1,34 +0,0 @@ -const Command = require('../../structures/Command'); -const Tag = require('../../models/Tag'); - -module.exports = class TagRemoveCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-remove', - aliases: ['tag-delete', 'remove-tag', 'delete-tag'], - group: 'tags', - memberName: 'remove', - description: 'Removes a tag from this server.', - guildOnly: true, - args: [ - { - key: 'name', - prompt: 'What is the name of the tag you want to remove?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - } - ] - }); - } - - async run(msg, { name }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); - if (!msg.channel.permissionsFor(msg.author).has('MANAGE_MESSAGES') && tag.userID !== msg.author.id) { - return msg.reply('You can only delete your own tags.'); - } - await tag.destroy(); - return msg.reply(`Removed **${name}**.`); - } -}; diff --git a/commands/tags/source.js b/commands/tags/source.js deleted file mode 100644 index b0308dd0..00000000 --- a/commands/tags/source.js +++ /dev/null @@ -1,29 +0,0 @@ -const Command = require('../../structures/Command'); -const Tag = require('../../models/Tag'); - -module.exports = class TagSourceCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-source', - group: 'tags', - memberName: 'source', - description: 'Responds with the base markdown of a tag in this server.', - guildOnly: true, - args: [ - { - key: 'name', - prompt: 'What is the name of the tag you want view the source of?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - } - ] - }); - } - - async run(msg, { name }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); - return msg.code('md', tag.text); - } -}; diff --git a/commands/tags/view.js b/commands/tags/view.js deleted file mode 100644 index 9b77646a..00000000 --- a/commands/tags/view.js +++ /dev/null @@ -1,30 +0,0 @@ -const Command = require('../../structures/Command'); -const Tag = require('../../models/Tag'); - -module.exports = class TagViewCommand extends Command { - constructor(client) { - super(client, { - name: 'tag-view', - aliases: ['tag', 'view-tag'], - group: 'tags', - memberName: 'view', - description: 'Responds with a tag in this server.', - guildOnly: true, - args: [ - { - key: 'name', - prompt: 'What is the name of the tag you want view?', - type: 'string', - max: 50, - parse: name => name.toLowerCase() - } - ] - }); - } - - async run(msg, { name }) { - const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); - return msg.say(tag.text); - } -}; diff --git a/models/Tag.js b/models/Tag.js deleted file mode 100644 index fd40ea13..00000000 --- a/models/Tag.js +++ /dev/null @@ -1,23 +0,0 @@ -const Sequelize = require('sequelize'); -const Database = require('../structures/PostgreSQL'); - -const Tag = Database.db.define('tag', { - userID: { - type: Sequelize.STRING, - allowNull: false - }, - guildID: { - type: Sequelize.STRING, - allowNull: false - }, - text: { - type: Sequelize.STRING, - allowNull: false - }, - name: { - type: Sequelize.STRING, - allowNull: false - } -}, { timestamps: true }); - -module.exports = Tag; diff --git a/package.json b/package.json index 9653ddb3..b0feedb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "81.0.6", + "version": "82.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {