我对 python 很陌生,好吧,我想制作一个发送 dm 的不和谐机器人,当其他用户收到 dm 时,他们会回复,代码的所有者或服务器的管理员将能够看到它说了什么!
这是我远的 dm 代码:
@client.command()
async def dm(ctx, user: discord.User, *, message):
await user.send(message)
如何才能看到用户对机器人的回复?
答案 0 :(得分:0)
为此,您可以将 client.wait_for()
与 check()
一起使用,因此在 await user.send(message)
之后添加:
def check(msg):
return msg.author == user and isinstance(msg.channel, discord.DMChannel)#check for what the answer must be, here the author has to be the same and it has to be in a DM Channel
try:
answer = await client.wait_for("message", check=check, timeout=600.0)#timeout in seconds, optional
await ctx.send(answer.content)
except asyncio.TimeoutError:
await author.send("Your answer time is up.")#do stuff here when the time runs out
如果这是您的 dm
函数。
参考文献: