在下面的代码中,我试图给使用表情符号回应消息的人一个角色,但是这段代码抛给我一个错误,告诉我'Member' has no attribute 'server',我现在应该怎么做?
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') 发布于 2021-10-24 06:28:29
首先,我们来看看the documentation。它会告诉你你需要知道的关于什么有什么属性的一切。此外,在discord.py中,服务器也被称为行会。所以改用user.guild.roles吧。
https://stackoverflow.com/questions/69694246
复制相似问题