【发布时间】:2020-10-10 06:47:18
【问题描述】:
我正在尝试为我最近开始编程的 discord.py 机器人添加结婚命令。我希望提到的用户能够回复机器人。
截至目前的代码,它只会回复我。
@client.command()
async def marry(ctx, member: discord.Member):
await ctx.send(f"{ctx.author.mention} **proposes to** {member.mention} **Do you accept??** "
f"\nRespond with [y(es)/n(o)]")
def check(m):
return m.author == ctx.author
try:
msg = await client.wait_for('message', check=check, timeout=10)
if msg.content.lower() in ['y', 'yes']:
await ctx.send(f"Congratulations! {ctx.author.mention} and {member.mention} are now married to each other!")
elif msg.content.lower() in ['n', 'no']:
await ctx.send(f"Unlucky, maybe another time! {ctx.author.mention}")
else:
await ctx.send("I did not understand that, aborting!")
except asyncio.TimeoutError as e:
print(e)
await ctx.send("Looks like you waited too long.")
有谁知道如何做到这一点,以便机器人可以识别来自上述用户(成员:discord.Member)的下一个回复,而不仅仅是我?
【问题讨论】:
标签: python discord discord.py discord.py-rewrite