Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. client.on('message', message => {
  2. let args = message.content.slice(prefix.length).split(' ')
  3. if (!message.content.startsWith(prefix)) return
  4. let i = 0
  5. if (args[0].toLowerCase() === 'ban') {
  6. okRoles.forEach(element => {
  7. if (message.member.roles.has(element)) i++
  8. })
  9. if (i = 0) {
  10. return message.channel.send('You do not have the correct role to use this command.')
  11. }
  12. if (!args[1]) {
  13. return message.channel.send('Make sure you mention someone, or give a valid user ID.')
  14. }
  15. let member = message.mentions.members.first() || message.guild.members.get(args[1])
  16. if (!member) {
  17. return message.channel.send('Could not find that user. Make sure you mention someone, or give a valid user ID.')
  18. }
  19. if (!message.guild.me.hasPermission('BAN_MEMBERS')) {
  20. return message.channel.send('I am missing permission: `Ban Members`.')
  21. }
  22. if (member.id === message.member.id) {
  23. return message.channel.send('You cannot ban yourself.')
  24. }
  25. if (member.id === client.user.id) {
  26. return message.channel.send('I cannot ban myself.')
  27. }
  28. let reason = args.slice(2).join(' ')
  29. message.channel.send(`Are you sure you want to ban **${member.user.tag}**?`)
  30. const filter = m => m.author.id === message.author.id
  31. const collector = message.channel.createMessageCollector(filter, { time: 999999 })
  32. collector.on('collect', m => {
  33. collector.stop()
  34. if (m.content.toLowerCase() === 'n' || m.content.toLowerCase() === 'no' || m.content.toLowerCase() === 'cancel') {
  35. return message.channel.send('Command cancelled.')
  36. }
  37. if (m.content.toLowerCase() === 'y' || m.content.toLowerCase() === 'yes' || m.content.toLowerCase() === 'sure') {
  38. return member.ban( { reason: reason } ).then(() => {
  39. message.channel.send(`Success! Banned **${member.user.tag}**\n For reason: \`${reason ? reason : `None provided`}\`.`)
  40. })
  41. }
  42. message.channel.send('Command cancelled. Next time, reply with a `yes` or a `no`.')
  43. })
  44. }
  45. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement