mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Tags
This commit is contained in:
@@ -12,7 +12,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
300 commands, she is one of the most feature-filled bots out there, and formerly
|
||||
served over 10,000 servers with a uniquely devoted fanbase.
|
||||
|
||||
## Commands (305)
|
||||
## Commands (311)
|
||||
### Utility:
|
||||
|
||||
* **prefix**: Shows or sets the command prefix.
|
||||
@@ -327,6 +327,14 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
||||
* **roman-numeral**: Converts a number to roman numerals.
|
||||
* **units**: Converts units to/from other units.
|
||||
|
||||
### Server Tags:
|
||||
* **tag**: Responds with a tag in this server.
|
||||
* **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 for this server.
|
||||
* **tag-source**: Responds with the base markdown of a tag in this server.
|
||||
|
||||
### Role Management:
|
||||
|
||||
* **add-open-role**: Sets a role as open.
|
||||
|
||||
@@ -31,6 +31,7 @@ client.registry
|
||||
['avatar-edit', 'Avatar Manipulation'],
|
||||
['text-edit', 'Text Manipulation'],
|
||||
['number-edit', 'Number Manipulation'],
|
||||
['tags', 'Server Tags'],
|
||||
['role-manage', 'Role Management'],
|
||||
['portal', 'Portal Messages'],
|
||||
['other', 'Other'],
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
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: 'id',
|
||||
prompt: 'What should the ID of the tag be?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What should the content of the tag be?',
|
||||
type: 'string',
|
||||
max: 1000
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id, text }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (tag) return msg.reply(`A tag with the ID **${id}** already exists.`);
|
||||
await Tag.create({
|
||||
userID: msg.author.id,
|
||||
guildID: msg.guild.id,
|
||||
id,
|
||||
text
|
||||
});
|
||||
return msg.reply(`Added the tag **${id}**.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
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: 'id',
|
||||
prompt: 'What is the ID of the tag you want to edit?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What should the new content of the tag be?',
|
||||
type: 'string',
|
||||
max: 1000
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id, text }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (!tag) return msg.reply(`A tag with the ID **${id}** 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: { id, guild: msg.guild.id } });
|
||||
return msg.reply(`Edited the tag **${id}**.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
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: 'id',
|
||||
prompt: 'What is the ID of the tag you want to get information on?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (!tag) return msg.reply(`A tag with the ID **${id}** 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('❯ ID', tag.id, 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);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
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 for this server.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'id',
|
||||
prompt: 'What is the ID of the tag you want to remove?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (!tag) return msg.reply(`A tag with the ID **${id}** 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 the tag **${id}**.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
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: 'id',
|
||||
prompt: 'What is the ID of the tag you want view the source of?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (!tag) return msg.reply(`A tag with the ID **${id}** doesn\'t exist.`);
|
||||
return msg.code('md', tag.text);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Tag = require('../../models/Tag');
|
||||
|
||||
module.exports = class TagCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tag',
|
||||
group: 'tags',
|
||||
memberName: 'tag',
|
||||
description: 'Responds with a tag in this server.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'id',
|
||||
prompt: 'What is the ID of the tag you want view?',
|
||||
type: 'string',
|
||||
max: 50,
|
||||
parse: id => id.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { id }) {
|
||||
const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } });
|
||||
if (!tag) return msg.reply(`A tag with the ID **${id}** doesn\'t exist.`);
|
||||
return msg.say(tag.text);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
},
|
||||
id: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
}, { timestamps: true });
|
||||
|
||||
module.exports = Tag;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "73.1.1",
|
||||
"version": "73.2.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user