Remove Tag and Role Management (no one uses and they suck)

This commit is contained in:
Daniel Odendahl Jr
2018-07-08 15:33:45 +00:00
parent 44d10df244
commit c0990a0b23
15 changed files with 3 additions and 441 deletions
+2 -20
View File
@@ -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.
-31
View File
@@ -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!`);
}
};
-30
View File
@@ -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.`);
}
};
-32
View File
@@ -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...`);
}
};
-24
View File
@@ -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')}
`);
}
};
-30
View File
@@ -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}**!`);
}
};
-30
View File
@@ -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}**...`);
}
};
-42
View File
@@ -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}**.`);
}
};
-40
View File
@@ -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}**.`);
}
};
-45
View File
@@ -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);
}
};
-34
View File
@@ -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}**.`);
}
};
-29
View File
@@ -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);
}
};
-30
View File
@@ -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);
}
};
-23
View File
@@ -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;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "81.0.6",
"version": "82.0.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {