nyx/unused/commands/Config/modmail-role.js

31 lines
885 B
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const schema = require("../../models/modmail");
module.exports = {
name: "modmail-role",
UserPerm: "ADMINISTRATOR",
description: "Add role for modmail in a server",
usage: "(Role)",
category: "Config",
run: async (client, message, args) => {
if (!args.length) return client.err(message, "Config", "modmail-role", 0);
const role =
2021-06-12 12:53:51 +02:00
message.mentions.roles.first() || message.guild.roles.cache.get(args[0]);
if (!role) return client.err(message, "Config", "modmail-role", 404);
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
if (data) {
data.Role = role.id;
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
}
else {
new schema({
Guild: message.guild.id,
Role: role.id,
}).save();
}
});
return message.channel.send({
content: `Updated **${role.name}** as the modmail role`,
});
},
2021-06-12 12:53:51 +02:00
};