(Discord.py) (Python) NoneType object error when trying to add roles -




i trying have bot discord able add roles. able create roles, fails when try , have give role somebody. here code:

    await client.send_message(message.channel, 'type in name of role have. cannot role exists.')      rolemessage = await client.wait_for_message(author = message.author)     rolename = str(rolemessage.content)      await client.create_role(client.get_server('insertserveridhere'), name = rolename, colour = discord.colour.orange(), hoist = true, mentionable = true)     userrole = discord.utils.get(message.server.roles, name = rolename)     await client.add_roles(message.author, userrole) 

i have tried looking @ other samples of code give people roles, , seem pretty similar. don't know problem is. whenever run it, says:

attributeerror: 'nonetype' object has no attribute 'id'

it says on line adds role.

edit: userrole appears problem on add_roles line, don't know why.

edit 2: reason changing server id different 1 , changing worked.

edit 3: reason when did on same server second time broke again. don't understand @ all.

edit 4: got work right making bot in between creating , adding role. theory didn't have time register role existed when tried add it.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -