【发布时间】:2022-01-22 11:55:02
【问题描述】:
我正在创建一个命令,该命令将从消息的反应中随机选择一个用户(类似于赠品命令)。我尝试添加一个功能,该功能将在机器人选择用户后删除所选用户的反应,但它不起作用。我是不和谐机器人世界的新手,请帮助我。
代码如下:
@client.command()
async def king(ctx):
time = 10
embed = nextcord.Embed(title="King's Game", description="React to join.")
embed.set_footer(text=f"Ends in {time}s")
kmsg = await ctx.send(embed=embed)
await kmsg.add_reaction("????")
await asyncio.sleep(time)
new_msg = await ctx.channel.fetch_message(kmsg.id)
players = await new_msg.reactions[0].users().flatten()
players.pop(players.index(client.user))
print (players)
king = random.choice(players)
tembed = nextcord.Embed(title="Time is up!", description="Get ready to obey the king.")
kembed = nextcord.Embed(title="King", description=f"{king.mention} is the king!")
await ctx.send(embed=tembed)
ktime = 2
await asyncio.sleep(ktime)
await ctx.send(embed=kembed)
kingid = get(king.user.id)
await kmsg.remove_reaction(kingid)
【问题讨论】:
标签: python discord discord.py nextcord