首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“‘Member”没有属性“server”

“‘Member”没有属性“server”
EN

Stack Overflow用户
提问于 2021-10-24 06:05:07
回答 1查看 49关注 0票数 0

在下面的代码中,我试图给使用表情符号回应消息的人一个角色,但是这段代码抛给我一个错误,告诉我'Member' has no attribute 'server',我现在应该怎么做?

代码语言:javascript
复制
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') 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-24 06:28:29

首先,我们来看看the documentation。它会告诉你你需要知道的关于什么有什么属性的一切。此外,在discord.py中,服务器也被称为行会。所以改用user.guild.roles吧。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69694246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档