I want to create a discord bot that, after receiving a message from the admin, changes the role of all server members (excluding the admin) from @everyone to @newrole.
I tried this code but there is an error:
role = discord.utils.get(server.roles, name="newrole")
AttributeError: 'NoneType' object has no attribute 'roles'
I use the latest version of discord and Python 3.6.
server = client.get_guild(int(server-id))
@client.event
async def on_message(message):
if message.content.startswith('change role'):
await message.author.send("Change the role from @everyone to @newrole")
role = discord.utils.get(server.roles, name="newrole")
for member in server.members:
await member.add_roles(role)