【发布时间】:2021-11-28 01:03:11
【问题描述】:
我一直在为我的 discord 机器人创建一个 connect 4 游戏,游戏本身运行良好, 但是如果有人删除了包含棋盘和用户玩游戏的反应的消息,游戏将开始中断并且无法正常运行,直到有人重新启动机器人:
turn = 0 #switches between 0 and 1 during the game
game_over = False
while not game_over:
try:
reaction, user = await client.wait_for("reaction_add", check = check)
if turn == 0:
#do stuff depending on what the emoji reaction is
if winning move():
game_over = True
else:
#do stuff depending on what the emoji reaction is
if winning_move():
game_over = True
#more things that aren't necessary to show
在有人删除消息和/或检查消息是否已被删除并通过它将变量更改为 True 后,我有没有办法将 game_over 更改为 True?
例如:
#If the board's not in the channel:
await message.channel.send("Board was not found")
game_over = True
任何帮助将不胜感激!
【问题讨论】:
标签: python discord discord.py