【发布时间】:2021-06-27 18:18:58
【问题描述】:
我的目标是制作一个小小的“轮盘赌”游戏。每个想玩的成员都应该能够对任何表情符号做出反应。但似乎我的代码只检测到第一反应。我想获得一个列表,哪个成员对哪个表情符号做出反应,以便稍后在代码中使用它。但现在的目标是为每个反应运行我的 IF 语句。希望你能明白我想要什么^^
@commands.command()
async def roulette(self, ctx, value: int):
msg = await ctx.send(f"Choose a color. Make sure you have at least {value} Kakera in your wallet!")
await msg.add_reaction("⚫")
await msg.add_reaction("????")
await msg.add_reaction("????")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["⚫", "????", "????"]
try:
reaction, user = await self.bot.wait_for('reaction_add', timeout=30, check=check)
await asyncio.sleep(5)
async for user in reaction.users():
await ctx.send('{0} has reacted with {1.emoji}!'.format(user, reaction))
print()
if str(reaction.emoji) == "⚫":
await ctx.send(f"Black from {user}!")
elif str(reaction.emoji) == "????":
await ctx.send(f"Red from {user}!")
elif str(reaction.emoji) == "????":
await ctx.send(f"Green from {user}!")
else:
print("Unknown reaction")
except asyncio.TimeoutError:
await ctx.send("Abort execution!")
【问题讨论】:
标签: python discord discord.py