Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # or use commands.guild_only() as a function decorator.
- if ctx.guild is None:
- await ctx.send("This command does not work outside guilds.")
- # check if the user who invoked the command can kick members.
- # could easily be replaced with commands.has_permissions(manage_messages=True)
- # as a function decorator
- elif ctx.author.guild_permissions.kick_members:
- # kick the member
- await member.kick()
- # notify the user that the member was kicked.
- # Member thas the method __str__()
- # which allows it to be formatted to username#discriminator
- await ctx.send(f"Successfully kicked {member}")
- # the member did not have the permissions to kick members
- else:
- await ctx.send(f"{ctx.author.mention}: You do not have permission to kick members.")
- # ---------------------------------------------
- # or use commands.guild_only() as a function decorator.
- if ctx.guild is None:
- await ctx.send("This command does not work outside guilds.")
- # check if the user who invoked the command can ban members.
- # or just have commands.has_permissions(ban_members=True)
- elif ctx.author.guild_permissions.ban_members:
- # ban the member
- await member.ban()
- # notify the user that the member was banned.
- await ctx.send(f"Successfully banned {member}")
- # the member did not have the permissions to ban members
- else:
- await ctx.send(f"{ctx.author.mention}: You do not have permission to ban members.")
- # ---------------------------------------------
- l = 100
- if limit > l:
- await ctx.send(f"The limit of messages to clear is 100.")
- # or use commands.guild_only() as a function decorator.
- elif ctx.guild is None:
- await ctx.send("This command does not work outside guilds.")
- # check if the user who invoked the command can manage messages.
- # or use commands.has_permissions(manage_messages=True)
- elif ctx.author.guild_permissions.kick_members:
- # purge the channel
- # +1 so it also deleted the command message.
- await ctx.channel.purge(limit+1)
- # notify the user that the messages where cleared, because he's blind or something, idk.
- await ctx.send(f"Successfully cleared {limit} messages.", delete_after=5)
- # the member did not have the permissions to kick users
- else:
- 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