2021-12-10 21:39:54 +05:00
|
|
|
const Command = require("../../base/Command.js"),
|
|
|
|
Discord = require("discord.js");
|
|
|
|
|
|
|
|
class Kick extends Command {
|
2021-12-26 19:29:37 +05:00
|
|
|
constructor(client) {
|
2021-12-10 21:39:54 +05:00
|
|
|
super(client, {
|
|
|
|
name: "kick",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: [],
|
2021-12-26 19:29:37 +05:00
|
|
|
memberPermissions: ["KICK_MEMBERS"],
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS", "KICK_MEMBERS"],
|
2021-12-10 21:39:54 +05:00
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
2021-12-22 17:32:50 +05:00
|
|
|
cooldown: 2000
|
2021-12-10 21:39:54 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-26 19:29:37 +05:00
|
|
|
async run(message, args, data) {
|
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.error("moderation/kick:MISSING_MEMBER");
|
|
|
|
|
2021-12-26 13:57:14 +05:00
|
|
|
if (member.id === message.author.id) return message.error("moderation/kick:YOURSELF");
|
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-11 01:11:50 +05:00
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
// Gets the kcik reason
|
|
|
|
let reason = args.slice(1).join(" ");
|
2021-12-11 01:11:50 +05:00
|
|
|
if (!reason) reason = message.translate("misc:NO_REASON_PROVIDED");
|
|
|
|
|
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");
|
|
|
|
if (!member.kickable) return message.error("moderation/kick:MISSING_PERM");
|
2021-12-10 21:39:54 +05:00
|
|
|
|
|
|
|
await member.send(message.translate("moderation/kick:KICKED_DM", {
|
|
|
|
username: member.user.tag,
|
|
|
|
server: message.guild.name,
|
|
|
|
moderator: message.author.tag,
|
|
|
|
reason
|
|
|
|
})).catch(() => {});
|
|
|
|
|
|
|
|
// Kick the user
|
|
|
|
member.kick(reason).then(() => {
|
|
|
|
// Send a success message in the current channel
|
|
|
|
message.sendT("moderation/kick:KICKED", {
|
|
|
|
username: member.user.tag,
|
|
|
|
server: message.guild.name,
|
|
|
|
moderator: message.author.tag,
|
|
|
|
reason
|
|
|
|
});
|
|
|
|
|
|
|
|
data.guild.casesCount++;
|
|
|
|
data.guild.save();
|
|
|
|
|
|
|
|
const caseInfo = {
|
|
|
|
channel: message.channel.id,
|
|
|
|
moderator: message.author.id,
|
|
|
|
date: Date.now(),
|
|
|
|
type: "kick",
|
|
|
|
case: data.guild.casesCount,
|
|
|
|
reason,
|
|
|
|
};
|
2021-12-11 01:11:50 +05:00
|
|
|
|
2021-12-10 21:39:54 +05:00
|
|
|
memberData.sanctions.push(caseInfo);
|
|
|
|
memberData.save();
|
2021-12-11 01:11:50 +05:00
|
|
|
|
|
|
|
if (data.guild.plugins.modlogs) {
|
2021-12-10 21:39:54 +05:00
|
|
|
const channel = message.guild.channels.cache.get(data.guild.plugins.modlogs);
|
2021-12-11 01:11:50 +05:00
|
|
|
if (!channel) return;
|
2021-12-10 21:39:54 +05:00
|
|
|
const embed = new Discord.MessageEmbed()
|
2021-12-26 19:29:37 +05:00
|
|
|
.setAuthor(message.translate("moderation/kick:CASE", {
|
|
|
|
count: data.guild.casesCount
|
|
|
|
}))
|
2021-12-10 21:39:54 +05:00
|
|
|
.addField(message.translate("common:USER"), `\`${member.user.tag}\` (${member.user.toString()})`, true)
|
|
|
|
.addField(message.translate("common:MODERATOR"), `\`${message.author.tag}\` (${message.author.toString()})`, true)
|
|
|
|
.addField(message.translate("common:REASON"), reason, true)
|
|
|
|
.setColor("#e88709");
|
|
|
|
channel.send(embed);
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
2021-12-10 21:39:54 +05:00
|
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
return message.error("moderation/kick:MISSING_PERM");
|
|
|
|
});
|
|
|
|
}
|
2021-12-11 01:11:50 +05:00
|
|
|
};
|
2021-12-10 21:39:54 +05:00
|
|
|
|
2021-12-11 01:11:50 +05:00
|
|
|
module.exports = Kick;
|