JaBa/commands/Moderation/unmute.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Unmute extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "unmute",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_MESSAGES"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS", "MANAGE_CHANNELS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args) {
2021-12-10 21:39:54 +05:00
const member = await this.client.resolveMember(args[0], message.guild);
2021-12-11 01:11:50 +05:00
if (!member) return message.success("moderation/unmute:MISSING_MEMBER");
2021-12-10 21:39:54 +05:00
const memberPosition = member.roles.highest.position;
const moderationPosition = message.member.roles.highest.position;
2021-12-11 01:11:50 +05:00
if (message.member.ownerID !== message.author.id && !(moderationPosition > memberPosition)) return message.error("moderation/ban:SUPERIOR");
2021-12-10 21:39:54 +05:00
2021-12-26 19:29:37 +05:00
const memberData = await this.client.findOrCreateMember({
id: member.id,
guildID: message.guild.id
});
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if (memberData.mute.muted) {
2021-12-10 21:39:54 +05:00
memberData.mute.endDate = Date.now();
memberData.markModified("mute");
memberData.save();
2021-12-26 19:29:37 +05:00
message.success("moderation/unmute:SUCCESS", {
username: member.user.tag
});
2021-12-10 21:39:54 +05:00
} else {
2021-12-26 19:29:37 +05:00
message.error("moderation/unmute:NOT_MUTED", {
username: member.user.tag
});
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Unmute;