【问题标题】:Discord.py help command (react to edit message)Discord.py 帮助命令(对编辑消息做出反应)
【发布时间】:2020-10-29 14:34:26
【问题描述】:

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

我看到了this post 对此,但这是一个箭头反应,我不知道如何将其更改为 0 1 2 3 4 反应。

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

我该怎么做?

【问题讨论】:

    标签: python python-3.x discord discord.py discord.py-rewrite


    【解决方案1】:

    这里我使用变量 (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
    

    【讨论】:

      猜你喜欢
      • 2019-05-24
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      • 2021-05-05
      • 1970-01-01
      • 2020-11-26
      相关资源
      最近更新 更多