nyx/commands/Moderation/unmute.js
2021-06-24 15:53:19 +08:00

47 lines
1.5 KiB
JavaScript

const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "unmute",
UserPerm: "MANAGE_MESSAGES",
BotPerm: "MANAGE_ROLES",
usage: "(User)",
description: "Unmute an user",
category: "Moderation",
run: async (client, message, args) => {
try {
const user =
message.mentions.members.first() ||
message.guild.members.cache.get(args[0]);
if (!user) return client.err(message, "Moderation", "unmute", 1);
const role = message.guild.roles.cache.find(r => r.name === "Muted");
if (!role) {
try {
await message.guild.roles.create({
data: {
name: "Muted",
permissions: [],
},
});
} catch (e) {
console.log(e);
return client.err(message, "Moderation", "unmute", 999);
}
}
await user.roles.remove(role);
const embed = new MessageEmbed()
.setTitle("User Unmuted")
.addField("**Moderator**", message.author.tag, true)
.addField("**User**", user.user.tag, true)
.setFooter(
message.member.displayName || message.author.username,
message.author.displayAvatarURL({ dynamic: true })
)
.setThumbnail(client.user.displayAvatarURL())
.setColor(client.color)
.setTimestamp();
message.inlineReply(embed);
} catch (e) {
console.log(e);
return client.err(message, "Moderation", "unmute", 999);
}
},
};