Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. # or use commands.guild_only() as a function decorator.
  2. if ctx.guild is None:
  3.     await ctx.send("This command does not work outside guilds.")
  4. # check if the user who invoked the command can kick members.
  5. # could easily be replaced with commands.has_permissions(manage_messages=True)
  6. # as a function decorator
  7. elif ctx.author.guild_permissions.kick_members:
  8.     # kick the member
  9.     await member.kick()
  10.     # notify the user that the member was kicked.
  11.     # Member thas the method __str__()
  12.     # which allows it to be formatted to username#discriminator
  13.     await ctx.send(f"Successfully kicked {member}")
  14.  
  15. # the member did not have the permissions to kick members
  16. else:
  17.     await ctx.send(f"{ctx.author.mention}: You do not have permission to kick members.")
  18.  
  19. # ---------------------------------------------
  20.  
  21. # or use commands.guild_only() as a function decorator.
  22. if ctx.guild is None:
  23.     await ctx.send("This command does not work outside guilds.")
  24. # check if the user who invoked the command can ban members.
  25. # or just have commands.has_permissions(ban_members=True)
  26. elif ctx.author.guild_permissions.ban_members:
  27.     # ban the member
  28.     await member.ban()
  29.     # notify the user that the member was banned.
  30.     await ctx.send(f"Successfully banned {member}")
  31.  
  32. # the member did not have the permissions to ban members
  33. else:
  34.     await ctx.send(f"{ctx.author.mention}: You do not have permission to ban members.")
  35.  
  36. # ---------------------------------------------
  37.  
  38. l = 100
  39. if limit > l:
  40.     await ctx.send(f"The limit of messages to clear is 100.")
  41. # or use commands.guild_only() as a function decorator.
  42. elif ctx.guild is None:
  43.     await ctx.send("This command does not work outside guilds.")
  44. # check if the user who invoked the command can manage messages.
  45. # or use commands.has_permissions(manage_messages=True)
  46. elif ctx.author.guild_permissions.kick_members:
  47.     # purge the channel
  48.     # +1 so it also deleted the command message.
  49.     await ctx.channel.purge(limit+1)
  50.     # notify the user that the messages where cleared, because he's blind or something, idk.
  51.     await ctx.send(f"Successfully cleared {limit} messages.", delete_after=5)
  52. # the member did not have the permissions to kick users
  53. else:
  54.     await ctx.send(f"{ctx.author.mention}: You do not have permission to delete messages.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement