client.on("message", (message) => {
if (message.member.hasPermission(["KICK_MEMBERS", "BAN_MEMBERS"])) {
if (message.content.startsWith(`${prefix}kick`)) {
let member = message.mentions.members.first();
if(!member) return message.channel.send('Cannot find this member');
member.kick().then((member) => {
message.channel.send("```" + member.displayName + " has been kicked ```");
});
}
}
This is the code of kick and ban.^^
- https://sourceb.in/2e6ba31dc3 - this is my discord bot code where I want to put the ban and kick command code
You want to put the command inside of the
client.on("message", (message)block. I'll use it in your code as an example:I hope this answers your question. Check the discordjs docs here if you haven't checked them already. They feature a nice tutorial on setting up your bot.