Skip to content

Commit

Permalink
Merge pull request #29 from sagamantus/main
Browse files Browse the repository at this point in the history
Add command to give single role to multiple members
  • Loading branch information
Aryan-401 authored Oct 10, 2022
2 parents 18e6cb3 + a14a030 commit b8f439a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ async def timeout(self, ctx, member: discord.Member, time: str = '10m', *, reaso
description=f'{member.mention} has been timed out for **{time}**',
colour=discord.Colour.blurple()))

@commands.command(aliases=['roleadd'], help="Gives specified roles to the provided members.")
@commands.has_permissions(manage_roles=True)
async def addrole(self, ctx: commands.Context, role: discord.Role, *members: discord.Member) -> None:
if members == tuple():
raise commands.MissingRequiredArgument(
self.addrole.params["members"])

if not ctx.guild.me.guild_permissions.manage_roles:
await ctx.send(embed=discord.Embed(
description=f"Bot doesn\'t have the permission to give roles.",
colour=discord.Colour.blurple()))
return

success = 0
for member in members:
await member.add_roles(role)
success += 1
await ctx.send(embed=discord.Embed(title="Member Roles",
description=f'Successfully added the role {role.mention} to {success} members.',
colour=discord.Colour.blurple()))


async def setup(client):
await client.add_cog(Moderation(client))

0 comments on commit b8f439a

Please sign in to comment.