【问题标题】:How to remove bot pagination response in discord.py如何在 discord.py 中删除机器人分页响应
【发布时间】:2020-10-08 13:04:00
【问题描述】:

所以我使用disputils 并且我已经嵌入了分页。但是,在它变得不活跃后,机器人会自动删除反应。我想让机器人删除整个嵌入,但我尝试了很多方法,例如使用 delete_after=(float) 甚至 asyncio,但它似乎不起作用。

@commands.group(aliases = ['ra'])
    async def red(self, ctx):
        if ctx.invoked_subcommand is None:
            default = discord.Embed(title="`test`",color=discord.Colour.dark_red())
            default.set_image(url="foo")
            default.set_footer(text="Image by| user")
            
            v1 = discord.Embed(title="example", description='test', color=discord.Colour.dark_red())
            v1.set_footer(text="Info taken from| website")
            
            v2 = discord.Embed(title="spam", description="foo" ,color=discord.Colour.dark_red())
            v2.set_footer(text="Info taken from| website")
            embeds = [
                default,
                v1,
                v2,           
            ]
            paginator = BotEmbedPaginator(ctx, embeds)
            await paginator.run()

我尝试在await paginator.run() 的括号内使用delete_after(float) 不起作用。尝试使用它 asycnio 格式并收到错误Instance of 'BotEmbedPaginator' has no 'delete' member。任何帮助将不胜感激。

【问题讨论】:

    标签: python pagination discord bots discord.py-rewrite


    【解决方案1】:

    只需使用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)
    

    【讨论】:

    • 顺便说一下链接是错误的。 pypi.org/project/DiscordUtils 这是您在项目之后添加的正确s :)。无论如何,非常感谢你,如果你可以编辑它,这样其他人将来可以使用你的评论也很好
    猜你喜欢
    • 2021-08-07
    • 2018-07-09
    • 2021-08-18
    • 2021-11-03
    • 2018-08-16
    • 2021-10-06
    • 1970-01-01
    • 2018-11-17
    • 2021-10-14
    相关资源
    最近更新 更多