gpt4 book ai didi

discord.py - 分页 - Discord.py 重写

转载 作者:行者123 更新时间:2023-12-05 01:37:36 30 4
gpt4 key购买 nike

我一直在尝试制作一个命令来显示一些信息,然后当我对表情使用react时,它应该会显示另一组信息。

我尝试使用 this 的部分内容,特别是第 335 到 393 行的部分让它工作。但是,它什么也不做。甚至没有错误消息。

这是我现在使用的代码。

            def check_react(reaction, user):
if reaction.message.id != msg.id:
return False
if user != ctx.message.author:
return False
return True
res, user = await bot.wait_for('reaction_add', check=check_react, timeout=None,)
if user != ctx.message.author:
print('if user != ctx.message.author:')
elif '⬅️' in str(res.emoji):
page -=1
print(page)
embed = discord.Embed(title='generic title', description='generic description', color=0x52fffc)
await msg.edit(embed=embed)
elif '➡️' in str(res.emoji):
page +=1
print(page)
embed = discord.Embed(title='generic title 2', description='generic description 2', color=0x52fffc)
await msg.edit(embed=embed)

好像停在了

await bot.wait_for('reaction_add', ..)

这是为什么呢?我怎样才能使代码工作?顺便说一句,这是一个齿轮。如果需要,我很乐意提供更多代码。

最佳答案

更好更简单的方法是使用 DiscordUtils

这是一个例子:

@commands.command()
async def paginate(self, ctx):
embed1 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 1")
embed2 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 2")
embed3 = discord.Embed(color=ctx.author.color).add_field(name="Example", value="Page 3")
paginator = DiscordUtils.Pagination.CustomEmbedPaginator(ctx, remove_reactions=True)
paginator.add_reaction('⏮️', "first")
paginator.add_reaction('⏪', "back")
paginator.add_reaction('🔐', "lock")
paginator.add_reaction('⏩', "next")
paginator.add_reaction('⏭️', "last")
embeds = [embed1, embed2, embed3]
await paginator.run(embeds)

关于discord.py - 分页 - Discord.py 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60877666/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com