Discord.py帮助命令(对编辑消息作出反应)

2024-05-29 03:45:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图发出一个帮助命令,如果您做出反应,它会将消息(编辑消息)更改为下一页(我有4个帮助页和一个默认页(显示什么数字=什么页面))

我看到了this post关于这一点,但这是一个箭头反应,我不知道如何将其更改为01 2 3 4反应

0 - help page
1 - fun commands
2 - Emoji commands
3 - admin commands
4 - misc commands

我该怎么做


Tags: 命令消息编辑adminpagehelp数字页面
1条回答
网友
1楼 · 发布于 2024-05-29 03:45:22

这里我使用一个变量(I)来跟踪页码。您首先发送一个嵌入(第0页)并获取消息对象(msg)

def reac_check(r, u):
   return msg.id == r.message.id and u!=self.bot.user and r.emoji in ['1','2','3']
i = 0
while True:
     try:
        reaction, user = await self.bot.wait_for('reaction_add', timeout=20.0, check=reac_check)
        em = str(reaction.emoji)
     except TimeoutError:
         print("caught")
         break #we exit the loop
      
     if user!=self.bot.user:
        await msg.remove_reaction(emoji=em, member=user)

     if em == '1':
        #edit message with embed of page 1
     #other cases go here

相关问题 更多 >

    热门问题