![](/img/trans.png)
[英]How do you make a discord bot respond without commands (but in python)?
[英]How do you make a discord bot respond to a back-and-forth?
你如何让机器人回复消息并提出问题,比如
我:!猜10
bot:在 1 到 10 之间选择一个数字
我:4
机器人:不正确,是 5!
我无法弄清楚如何做到这一点,因为一旦您响应命令,我不知道如何使用全局变量之类的东西来保存答案。
这是我使用的一些代码,希望这会有所帮助,这会给您 5 次猜测以使其正确!
@commands.command()
async def game(self, ctx):
number = random.randint(0, 100)
for i in range(0, 5):
await ctx.send('guess')
response = await self.bot.wait_for('message')
guess = int(response.content)
if guess > number:
await ctx.send('bigger')
elif guess < number:
await ctx.send('smaller')
else:
await ctx.send('yes!')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.