[英]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.