I wanted to add a kick command to my discord bot, which uses the await function.The only way i know to async run is
client.on("message", async (message) => {
however, I cannot do this in a command file inside the commands folder My kick command
const { MessageEmbed } = require("discord.js");
module.exports = {
name: "kick",
description: "kicks a member",
execute(client, args) {
if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("Invalid Permissions")
let member = message.mentions.members.first()
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.kickable)
return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
await member.kick(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`)
}}
Sorry if this seems like a stupid question, Im pretty new to coding
./commands/${file}
); client.commands.set(command.name, command); };