简体   繁体   中英

How can I make a ban command for my discord.js bot?

const Discord = require('discord.js');
const config = require('../config.json');
const log = require(`leekslazylogger`);
module.exports = {
  name: 'ban',
  description: 'This is for admins only',
  usage: '',
  aliases: ['Ban'],
  example: '',
  args: false,
  cooldown: config.cooldown,
  guildOnly: true,
  execute(message, args) {
    const client = message.client;
    // command starts here
    message.delete();

That's all I have so far. I don't how to make a ban command and I have tried making one but every time I did, I got a lot of errors when the bot starts up. Anyone know how to do this?

Ill give you some code that u may edit to avoid "clone".

You can edit it to do it an embed, if u want here is it:

if (!message.member.hasPermission('BAN_MEMBERS'))
  return message.channel.send(
    "You can't use that!\nYou need the 'Ban Members' permission"
  );
let member = message.mentions.members.first();
let reason = args.slice(1).join(' ');
if (!member) {
  message.delete();
  message.channel.send('You need mention someone!');
} else {
  message.delete();
  message.channel.send(
    '<@' + member + '> Has been successfully banned from the guild'
  );
  member.ban(member, reason);
  console.log(`Banned someone on:\n ${message.guild.name} `);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM