Skip to content
Advertisement

discord.py the bot doesn’t give the role provided upon member join

I tried to set up this bot event where it would give a role to the member that joins. For some reason, it doesn’t give the role, but it doesn’t give any error output either.

JavaScript

Advertisement

Answer

JavaScript

There are a few issues with your code

  • in line 2, the function is not async, discord.py events need to be async so replace def with async def
  • in line 3, ids are always ints, so you would make it an int, but you shouldn’t even use discord.utils.get since you can just do member.guild.get_role(id). Note: id has to be int
  • in line 4, client.add_roles is outdated, it was replaced by member.add_roles. So you would have to change client.add_roles(member, role) to member.add_roles(role)

So the full updated code would be

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement