【发布时间】:2020-06-08 02:45:51
【问题描述】:
所以,我正在尝试为我的机器人执行一个不和谐的命令。命令是每次用户进入服务器时,机器人都会向用户打招呼并询问其名称。然后用户回复一条包含其名称的消息,然后机器人将服务器中用户的昵称更改为第一个用户回复的昵称。所以fa我没有运气找到如何但是我制作了这个代码并且它发送了dm并阅读了回复,但是它没有改变昵称,有什么帮助吗?
编辑:所以我听从了某人的建议,这就是编码所发生的事情
@client.event
async def on_member_join(member):
await member.send(f"""Welcome to the server {member.name}!""")
await member.send("Please enter your full name: ")
def check(m): #checks if message was sent by someone other than the bot
return m.author != client.user
name = await client.wait_for('message', check=check)
await name.author.edit(nick=name.content)
现在的问题是,每当我尝试用最后一行更改昵称时,都会弹出此错误:
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/Users/bermed28/opt/anaconda3/envs/pyBot/lib/python3.6/site-packages/discord/client.py", line 303, in _run_event
await coro(*args, **kwargs)
File "/Users/bermed28/Desktop/pyBot/bot.py", line 56, in on_member_join
await name.author.edit(nick=name.content)
AttributeError: 'User' object has no attribute 'edit'
【问题讨论】:
-
client.event这样不行,考虑使用wait_fordiscordpy.readthedocs.io/en/latest/… -
我刚试了,看编辑后的帖子!弹出另一个错误!
标签: python discord.py discord.py-rewrite