Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on('message', message => {
- let args = message.content.slice(prefix.length).split(' ')
- if (!message.content.startsWith(prefix)) return
- let i = 0
- if (args[0].toLowerCase() === 'ban') {
- okRoles.forEach(element => {
- if (message.member.roles.has(element)) i++
- })
- if (i = 0) {
- return message.channel.send('You do not have the correct role to use this command.')
- }
- if (!args[1]) {
- return message.channel.send('Make sure you mention someone, or give a valid user ID.')
- }
- let member = message.mentions.members.first() || message.guild.members.get(args[1])
- if (!member) {
- return message.channel.send('Could not find that user. Make sure you mention someone, or give a valid user ID.')
- }
- if (!message.guild.me.hasPermission('BAN_MEMBERS')) {
- return message.channel.send('I am missing permission: `Ban Members`.')
- }
- if (member.id === message.member.id) {
- return message.channel.send('You cannot ban yourself.')
- }
- if (member.id === client.user.id) {
- return message.channel.send('I cannot ban myself.')
- }
- let reason = args.slice(2).join(' ')
- message.channel.send(`Are you sure you want to ban **${member.user.tag}**?`)
- const filter = m => m.author.id === message.author.id
- const collector = message.channel.createMessageCollector(filter, { time: 999999 })
- collector.on('collect', m => {
- collector.stop()
- if (m.content.toLowerCase() === 'n' || m.content.toLowerCase() === 'no' || m.content.toLowerCase() === 'cancel') {
- return message.channel.send('Command cancelled.')
- }
- if (m.content.toLowerCase() === 'y' || m.content.toLowerCase() === 'yes' || m.content.toLowerCase() === 'sure') {
- return member.ban( { reason: reason } ).then(() => {
- message.channel.send(`Success! Banned **${member.user.tag}**\n For reason: \`${reason ? reason : `None provided`}\`.`)
- })
- }
- message.channel.send('Command cancelled. Next time, reply with a `yes` or a `no`.')
- })
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement