nyx/unused/commands/Config/rr-add.js

47 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2021-06-12 12:53:51 +02:00
const { Client, Message, MessageEmbed, Util } = require("discord.js");
const Schema = require("../../models/reaction");
module.exports = {
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]);
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
};