Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const commando = require('discord.js-commando');
- const app = require('../../app.js');
- const config = require('../../config.json');
- const Discord = require('discord.js');
- class banCommand extends commando.Command {
- constructor(client){
- super(client, {
- name: `ban`,
- group: 'message',
- memberName: 'ban',
- description: 'bans the user mentioned.',
- examples: [ 'Ban <@user> being bad!' ]
- });
- }
- async run(message, args){
- // Most of this command is identical to kick, except that here we'll only let admins do it.
- // In the real world mods could ban too, but this is just an example, right? ;)
- if (!message.member.roles.some(r => ["Administrator"].includes(r.name)))
- return message.reply("Sorry, you don't have permissions to use this!");
- let member = message.mentions.members.first();
- if (!member)
- return message.reply("Please mention a valid member of this server");
- if (!member.bannable)
- return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
- let reason = args.slice(1).join(' ');
- if (!reason) reason = "No reason provided";
- await member.ban(reason)
- .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
- message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement