2021-06-12 12:53:51 +02:00
|
|
|
const { Client, Message, MessageEmbed, Util } = require("discord.js");
|
|
|
|
const Schema = require("../../models/reaction");
|
|
|
|
module.exports = {
|
2021-11-18 18:56:42 +01:00
|
|
|
name: "rr-add",
|
|
|
|
UserPerm: "ADMINISTRATOR",
|
|
|
|
description: "Create reaction role for server",
|
|
|
|
usage: "(Role) (emoji(Must be in server)",
|
|
|
|
category: "Config",
|
|
|
|
run: async (client, message, args) => {
|
|
|
|
const role =
|
2021-06-12 12:53:51 +02:00
|
|
|
message.mentions.roles.first() ||
|
|
|
|
message.guild.roles.cache.get(args[0]) ||
|
|
|
|
message.guild.roles.cache.find(r => r.name == args[0]);
|
2021-11-18 18:56:42 +01:00
|
|
|
const [, emoji] = args;
|
|
|
|
if (!emoji) return client.err(message, "Config", "rr-add", 11);
|
|
|
|
const parsedEmoji = Util.parseEmoji(emoji);
|
|
|
|
Schema.findOne({ Guild: message.guild.id }, async (err, data) => {
|
|
|
|
if (data) {
|
|
|
|
data.Roles[parsedEmoji.name] = [
|
|
|
|
role.id,
|
|
|
|
{
|
|
|
|
id: parsedEmoji.id,
|
|
|
|
raw: emoji,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
await Schema.findOneAndUpdate({ Guild: message.guild.id }, data);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
new Schema({
|
|
|
|
Guild: message.guild.id,
|
|
|
|
Message: 0,
|
|
|
|
Roles: {
|
|
|
|
[parsedEmoji.name]: [
|
|
|
|
role.id,
|
|
|
|
{
|
|
|
|
id: parsedEmoji.id,
|
|
|
|
raw: emoji,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}).save();
|
|
|
|
}
|
|
|
|
message.channel.send(`Added ${role.name}.`);
|
|
|
|
});
|
|
|
|
},
|
2021-06-12 12:53:51 +02:00
|
|
|
};
|