我一直在尝试创建一个命令来显示一些信息,然后,当我对表情做出反应时,它应该显示另一组信息。
\n我尝试使用其中的一部分部分内容,特别是第 335 行至 393 行中的部分\n以使其正常工作。然而,它什么也没做。甚至没有错误消息。
\n这是我现在使用的代码。
\n def check_react(reaction, user):\n if reaction.message.id != msg.id:\n return False\n if user != ctx.message.author:\n return False\n return True\n res, user = await bot.wait_for(\'reaction_add\', check=check_react, timeout=None,)\n if user != ctx.message.author:\n print(\'if user != ctx.message.author:\')\n elif \'\xe2\xac\x85\xef\xb8\x8f\' in str(res.emoji):\n page -=1\n print(page)\n embed = discord.Embed(title=\'generic title\', description=\'generic description\', color=0x52fffc)\n await msg.edit(embed=embed)\n elif \'\xe2\x9e\xa1\xef\xb8\x8f\' in str(res.emoji):\n page +=1\n print(page)\n embed = discord.Embed(title=\'generic title 2\', description=\'generic description 2\', color=0x52fffc)\n await msg.edit(embed=embed)\nRun Code Online (Sandbox Code Playgroud)\n似乎停在
\n\n\n等待 bot.wait_for(\'reaction_add\', ..)
\n
这是为什么?我怎样才能使代码工作?顺便说一句,那是在齿轮中。如果需要,我很乐意提供更多代码。
\n小智 5
更好、更简单的方法是使用DiscordUtils
\n这是一个例子:
\n@commands.command()\nasync def paginate(self, ctx):\n embed1 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 1")\n embed2 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 2")\n embed3 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 3")\n paginator = DiscordUtils.Pagination.CustomEmbedPaginator(ctx, remove_reactions=True)\n paginator.add_reaction(\'\xe2\x8f\xae\xef\xb8\x8f\', "first")\n paginator.add_reaction(\'\xe2\x8f\xaa\', "back")\n paginator.add_reaction(\'\', "lock")\n paginator.add_reaction(\'\xe2\x8f\xa9\', "next")\n paginator.add_reaction(\'\xe2\x8f\xad\xef\xb8\x8f\', "last")\n embeds = [embed1, embed2, embed3]\n await paginator.run(embeds)\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
7765 次 |
| 最近记录: |