0
votes

i can't get my bot to add roles. what am i doing wrong here?

class MyClient(discord.Client):
    async def on_voice_state_update(member, before, after):
        role = get(member.server.roles, name="babbelaar")
        if after.channel is None:
            member.add_roles([role.id])
        else:
            member.remove_roles([role.id])

i want a user that joins a voice channel to get a certain role, and that role to be removed after the user leaves the voice channel

1

1 Answers

0
votes

You need to await adding/removing roles, and pass the roles as an argument list of Role objects (instead of passing a list):

await member.add_roles(role)