#๐Ÿ”’ Assign multiple users a role in discord.py

4 messages ยท Page 1 of 1 (latest)

waxen talon
#

Hi, im making a bot for my server in discord.py and ive ran into trouble with my role command. I can't find or think of a way to allow you to enter in multiple users at once to receive the role instead of having to do the command one by one, can anyone help with this? im new to discord.py so im still working stuff out.

here is my current command, im not averse to completely changing the logic of the command or anything:

@bot.command()
async def role(ctx, user : discord.Member, *, role : discord.Role):
  if role.position > ctx.author.top_role.position:
    return await ctx.send('That role is too high.') 
  if role in user.roles:
      await user.remove_roles(role)
      await ctx.send(f"Removed {role} from {user}")
  else:
      await user.add_roles(role)
      await ctx.send(f"Added {role} to {user}")  
marsh stumpBOT
#

@waxen talon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

marsh stumpBOT
#

@waxen talon

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.