【发布时间】:2021-08-01 21:29:07
【问题描述】:
当人们想使用我的反馈命令提供有关机器人的反馈时,我希望能够通过机器人将他们 dm 回复,但我的 DM 命令不起作用,即使他们与机器人有一个共同的服务器。当我运行该命令时,我收到此错误:/usr/lib/python3.7/asyncio/events.py:88: RuntimeWarning: coroutine 'Client.fetch_user' was never awaited。谁能帮我这个?这是我的代码:
@client.command(description="This command DMs people and can only be used by the owner.")
@commands.is_owner()
async def dm(ctx, id, *, message):
user = await client.fetch_user(id)
await user.send(message)
return
【问题讨论】:
-
正如错误所说,你应该等待
client.fetch_user,因为它是一个协程 -
哦,好的,我现在明白了。我会解决的。我还是 dpy 的新手,这就是为什么我有时会搞砸一些愚蠢的事情
-
@ŁukaszKwieciński 我做到了,但是机器人仍然只能在服务器中运行命令的人。你知道为什么吗?
-
我不太明白,介意改写吗?
标签: python python-3.x discord.py