master
Kit Kasune 4 years ago
parent eead4ca8bb
commit 4b1f962982
  1. 15
      .idea/workspace.xml
  2. 66
      commands/kick.js

@ -2,10 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="977e7f53-d837-472d-98d5-0d19ca269f67" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/Natsuki.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Natsuki.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bot.js" beforeDir="false" afterPath="$PROJECT_DIR$/bot.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/events/ready.js" beforeDir="false" afterPath="$PROJECT_DIR$/events/ready.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/commands/clearwarnings.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/clearwarnings.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/commands/response.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/response.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/commands/welcome.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/welcome.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -31,8 +31,8 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="javascript.nodejs.core.library.configured.version" value="14.15.4" />
<property name="javascript.nodejs.core.library.typings.version" value="14.14.21" />
<property name="javascript.nodejs.core.library.configured.version" value="12.18.3" />
<property name="javascript.nodejs.core.library.typings.version" value="12.19.15" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
@ -66,6 +66,9 @@
<workItem from="1610796096772" duration="93000" />
<workItem from="1610796205825" duration="1950000" />
<workItem from="1610841807978" duration="1127000" />
<workItem from="1611872285922" duration="326000" />
<workItem from="1611931047924" duration="34000" />
<workItem from="1612003645899" duration="25000" />
</task>
<servers />
</component>

@ -0,0 +1,66 @@
const Discord = require('discord.js');
const Mod = require('../models/mod');
const {Tag} = require('../util/tag');
const {TagFilter} = require('../util/tagfilter');
module.exports = {
name: "kick",
aliases: ['kicc', 'k'],
meta: {
category: 'Moderation',
description: "Kicks a user from the server!",
syntax: '`kick <@user|userID> [reason]`',
extra: null,
guildOnly: true
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Kick")
.setDescription("Kicks a user from the server!")
.addField("Syntax", "`kick <@user|userID> [reason]`")
.addField("Notice", "This command requires you to have `kick` permissions in the server."),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}kick <@user|userID> [reason]\``);}
if (!message.member.permissions.has("KICK_MEMBERS")) {return message.channel.send("You don't have permissions to do that!");}
if (!message.guild.me.permissions.has("KICK_MEMBERS")) {return message.channel.send("I don't have permissions to kick members in your server.");}
let user = message.guild.members.cache.get(args[0]) || message.mentions.members.first();
if (!user) {return message.channel.send("You must mention a user to kick, or provide their ID.");}
if (user.roles.highest.position >= message.member.roles.highest.position) {return message.channel.send("You don't have permissions to kick that member as they are above you in the roles list.");}
if (user.roles.highest.position >= message.guild.me.roles.highest.position) {return message.channel.send("I can't kick that member as their highest role is above mine! (Or the same as mine, too)");}
if (!user.kickable) {return message.channel.send("For some reason, I can't kick that user!");}
let options = new TagFilter([
new Tag(['r', 'reason'], 'reason', 'append'),
new Tag(['n', 'notes'], 'notes', 'append')
]).test(args.join(" "));
let reason;
if (options.notes && options.notes.length) {
if (options.reason && options.reason.length) {reason = options.reason;}
if (options.notes.length > 250) {return message.channel.send("Hey, listen, let's not write an essay on why you're kicking that member!");}
}
else {if (args[1]) {args.shift(); reason = args.join(" ");}}
if (reason && reason.length > 250) {return message.channel.send("Hey, listen, let's not write an essay on why you're kicking that member!");}
return user.kick(reason)
.then(async () => {
let mh = await Mod.findOne({gid: message.guild.id}) || new Mod({gid: message.guild.id});
let mhcases = mh.cases;
mhcases.push({
members: [user.id],
punishment: "Kicked",
reason: reason ? reason : "",
status: "Closed",
moderators: [message.author.id],
notes: options.notes,
history: [`${new Date().toISOString()} - ${message.author.username} - Created case`, `${new Date().toISOString()} - ${message.author.username} - Kicked ${client.users.cache.get(user.id).username}`],
issued: new Date().toUTCString()
});
mh.cases = mhcases;
mh.save();
return message.channel.send("I got em outta here!");
})
.catch(() => {return message.channel.send("Something went wrong while trying to kick that user! If the problem persists, contact my devs.");});
}
};
Loading…
Cancel
Save