Skip to content
Advertisement

‘Member’ has no attribute ‘server’

In the given code below I was trying to give a role to the person who reacts to a message by using any emoji but this code throws me an error saying that 'Member' has no attribute 'server' what should I do now?

import discord
from discord.ext import commands
import random

client = discord.Client()





@client.event
async def on_ready():
 print('ready')

@client.event
async def on_reaction_add(reaction, user):
  channel = reaction.message.channel

  await channel.send(f'{user.name} has reacted by using    {reaction.emoji} emoji, his message was {reaction.message.content}')

  role = discord.utils.get(user.server.roles, name = 'Bot')

  await client.add_roles(user, role)

client.run('TOKEN') 

Advertisement

Answer

First off take a look at the documentation. It’ll tell you everything you need to know about what has what attributes. Also, server is called guild in discord.py. So use user.guild.roles instead.

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