Haha-Yes/commands/admin/ban.js

70 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-12-30 01:20:24 +01:00
const { Command } = require('discord-akairo');
2018-12-25 19:17:07 +01:00
2018-12-30 01:20:24 +01:00
class BanCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor() {
super('ban', {
aliases: ['ban'],
category: 'admin',
args: [
{
2019-12-30 15:38:58 +01:00
id: 'user',
type: 'string',
2019-06-23 03:41:59 +02:00
prompt: {
2019-12-30 15:38:58 +01:00
start: 'which user do you want to ban?',
retry: 'This doesn\'t look like a user, please try again!'
2019-06-23 03:41:59 +02:00
}
2019-01-02 08:09:45 +01:00
},
{
id: 'reasons',
2019-01-14 11:41:15 +01:00
type: 'string',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'For what reasons?',
optional: true
},
2019-01-14 11:41:15 +01:00
match: 'rest'
2019-01-02 08:09:45 +01:00
}
],
2019-11-09 12:04:01 +01:00
clientPermissions: ['BAN_MEMBERS', 'SEND_MESSAGES'],
2019-01-02 08:09:45 +01:00
userPermissions: ['BAN_MEMBERS'],
2020-03-19 23:24:31 +01:00
channel: 'guild',
2019-01-02 08:09:45 +01:00
description: {
2019-12-30 15:38:58 +01:00
content: 'Ban user | For hackban precise the userid',
usage: '[@user] [reason] OR [userID] [reason]',
examples: ['@user big dumb dumb', 'userID hackban']
2019-01-02 08:09:45 +01:00
}
});
}
2018-09-07 19:07:10 +02:00
2019-01-02 08:09:45 +01:00
async exec(message, args) {
let reasons = args.reasons;
2019-12-30 15:38:58 +01:00
let user = args.user;
if (message.mentions.members.first())
user = message.mentions.members.first().id;
2018-12-30 01:20:24 +01:00
2019-12-30 15:38:58 +01:00
if(user === this.client.user.id)
return message.channel.send('Can\'t ban me fool!');
2019-01-02 08:09:45 +01:00
if(!reasons)
reasons = 'Nothing have been specified';
2019-12-30 15:38:58 +01:00
if(user === message.author.id)
2019-01-02 08:09:45 +01:00
return message.channel.send('Why would you ban yourself ?');
2018-12-25 19:17:07 +01:00
2019-12-30 15:38:58 +01:00
if (message.mentions.members.first()) {
user = message.mentions.members.first();
await user.send(`You have been banned from **${message.guild.name}** for the following reasons: "**${reasons}**"`, {files: ['./asset/vid/You_Have_Been_Banned_From_Mickey_Mouse_Club.mp4']})
.catch(() => console.log('could not send message to the concerned user'));
return user.ban({reason: `Banned by : ${message.author.username} for the following reasons : ${reasons}`})
.then(() => message.reply(`${user.user.username} was succesfully banned with the following reasons "${reasons}".`))
//.catch(() => message.reply('Uh oh, an error has occurred! can the bot ban this user?'));
2019-12-30 15:38:58 +01:00
.catch(err => console.error(err));
2019-12-30 15:38:58 +01:00
} else {
message.guild.members.ban(user, {reason: `Banned by : ${message.author.username} for the following reasons : ${reasons}`})
.then(() => message.reply(`user ID ${args.user} was succesfully hackbanned with the following reasons "${reasons}".`))
//.catch(() => message.reply('Uh oh, an error has occurred! can the bot ban this user?'));
2019-12-30 15:38:58 +01:00
.catch(err => console.error(err));
}
2019-01-02 08:09:45 +01:00
}
2018-12-30 01:20:24 +01:00
}
2018-12-06 20:11:21 +01:00
2018-12-30 01:20:24 +01:00
module.exports = BanCommand;