So I've been trying to figured out how to use the add_roles() method but I run into the issue of not being able to find out how to obtain a specific role object and also was wondering if the member argument was suppose to be a user ID# or the users name. I'm new to this whole thing so an explanation with an example would be a preferred means of response if possible.
When using add_roles() you should pass in a member object. To obtain a specific role object you should use the discord.utils.get() function.
In the example below we are first retrieving the role. Note how we need an instance of the server to do this. Also note that the this is an attribute search so name could be, for example id, or even both. See the documentation for more information. Next we are using the add_roles() function passing in, first the member object and then the role we just retrieved.
Example:
role = discord.utils.get(server.roles, name="admin")
await client.add_roles(member, role)
If you are having problems with discord.py I would recommend reading the documentation and/or reading through the code of other bots using discord.py on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With