mrmBot-Matrix/commands/kick.js

23 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-09-13 20:02:41 +00:00
const client = require("../utils/client.js");
exports.run = async (message) => {
if (!message.channel.guild) return `${message.author.mention}, this command only works in servers!`;
2019-09-13 20:02:41 +00:00
if (!message.member.permission.has("kickMembers")) return `${message.author.mention}, you need to have the \`Kick Members\` permission on this server to kick people!`;
if (!message.channel.guild.members.get(client.user.id).permission.has("kickMembers") && !message.channel.permissionsOf(client.user.id).has("kickMembers")) return `${message.author.mention}, I don't have the \`Kick Members\` permission!`;
const member = message.mentions[0];
if (member) {
try {
await message.channel.guild.kickMember(member.id, `kick command used by @${message.author.username}#${message.author.discriminator}`);
2019-09-13 20:02:41 +00:00
return `Successfully kicked ${member.mention}.`;
} catch (error) {
throw error;
//return `${message.author.mention}, I was unable to kick the member. Have you given me permissions?`;
2019-09-13 20:02:41 +00:00
}
} else {
return `${message.author.mention}, you need to provide a member to kick!`;
}
};
exports.category = 2;
exports.help = "Kicks a member";
exports.params = "[mention]";