【发布时间】:2021-10-13 16:19:52
【问题描述】:
我正在寻求以下代码的帮助:
if message.content.startswith("keycode"):
channel = bot.get_channel(00000000000000)
await channel.send('sentence 1')
await asyncio.sleep(3)
await channel.send('sentence 2.')
await asyncio.sleep(3)
await channel.send('Please reply "yes" or "no".')
try:
await bot.wait_for('message', timeout=15.0)
except asyncio.TimeoutError:
await channel.send('You ran out of time to answer!')
if message.content == 'yes':
await channel.send('You replied yes')
else:
await channel.send('You didn't reply yes.')
基本上,根据请求,discord 机器人会对所选频道做出响应,然后在响应之后询问用户是否可以回复“是”或“否”。然后,如果用户回答“是”,它会给出“你回答是”的响应,如果不是,它会给出“你没有回答是”的响应。
我的问题是,每当我运行命令并在其响应后键入“是”时,我总是得到“您没有回答是”响应”。(它确实发送“您没有时间回答”如果我在给定的时间范围内没有回复,请回复)。
我对这一切都很陌生,所以如果有人能找出我所有的错误,那就太好了。提前致谢。
【问题讨论】:
标签: discord discord.py bots