【发布时间】:2020-11-03 04:02:15
【问题描述】:
elif "!bingo" in message.content.lower():
await message.channel.send("Here's your miniature Bingo sequence")
shuffled = shuffle(bingo)
await message.channel.send(bingo[0:3])
await message.channel.send(bingo[3:6])
await message.channel.send(bingo[6:9])
channel = message.channel
while userinput != "bingo":
await message.channel.send("Type anything to move on, or type bingo to end!")
def check(m):
return m.channel == channel
userinput[0](str(m.content))
if message.author == client.user:
return
else:
msg = await client.wait_for('message', check=check)
if str(userinput) == "bingo":
break
else:
await message.channel.send(random.randint(1,9))
当您输入宾果游戏时,该函数应该会中断,但由于某种原因,用户输入字符串没有任何值。它在前面的代码中定义,所以它不是问题的原因。
请帮忙谢谢
【问题讨论】:
-
谢谢大家,我找到了解决办法。两个 cmets 都没有完全解决问题(尽管第二条评论帮助我找到了存在的问题),循环很好,但问题是您无法将
str(userinput)与字符串进行比较,因为userinput变量是列表。一个非常业余的错误。不管怎样,if 语句被修改为if "bingo" in userinput:。其他一切都保持不变。再次感谢您的帮助! -
您可以自己回答并接受您的问题,这有助于其他人在将来找到这个答案。
标签: python discord discord.py