我正在制作一個命令,該命令將從訊息的反應中隨機選擇一個用戶(類似于贈品命令)。我嘗試添加一個功能,該功能將在機器人選擇用戶后洗掉所選用戶的反應,但它不起作用。我是不和諧機器人世界的新手,請幫助我。
以下是代碼:
@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)
uj5u.com熱心網友回復:
您應該閱讀await remove_reaction(emoji, member)官方檔案。
您必須簡單地指定洗掉反應的成員。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/418635.html
標籤:
