猿问

Discord.py 分页

所以我想让嵌入分页,这样它就可以在对表情符号做出反应时改变我找到了一个名为disputils的项目,它使过程变得更容易,但它支持文本,而且无论如何我可以在这段代码中包含图片(文档有没有示例或说可以嵌入图片任何帮助将不胜感激):


@bot.command()

async def paginate(ctx):

    embeds = [

        Embed(title="test page 1", description="This is just some test content!", color=0x115599),

        Embed(title="test page 2", description="Nothing interesting here.", color=0x5599ff),

        Embed(title="test page 3", description="Why are you still here?", color=0x191638)

    ]


    paginator = BotEmbedPaginator(ctx, embeds)

    await paginator.run()

我也尝试过使用 embed.set_image 但出现错误positional argument follows keyword argument (<unknown>, line 12)(它突出显示了 embed.set_image)


绝地无双
浏览 1604回答 2
2回答

慕的地10843

尝试使用Embed.set_image单独的变量,然后将该变量包含在嵌入列表中:@bot.command()async def paginate(ctx):    e = Embed(title="test page 1", description="foo", color=0x115599)    e.set_image(url="foo.png")        embeds = [        e,        Embed(title="test page 2", description="bar", color=0x5599ff)    ]    paginator = BotEmbedPaginator(ctx, embeds)    await paginator.run()

翻翻过去那场雪

您可以做的一件事是描述列表之外的嵌入。它应该工作得很好,就像它对我来说一样。我包含了缩略图和图像选项,因为我不确定“图像”是什么意思。pip install disputils在尝试将代码放入文件之前,请确保您已在终端中进行了操作。这是代码:import discordfrom disputils import BotEmbedPaginator, BotConfirmation, BotMultipleChoicebot = commands.Bot(command_prefix='!')@bot.command()async def testing(ctx):&nbsp; &nbsp; Embed1 = discord.Embed(title="Title", description="Description", color=0x000000)&nbsp; &nbsp; Embed1.set_image(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; Embed1.set_thumbnail(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; Embed2 = discord.Embed(title="Title", description="Description", color=0x000000)&nbsp; &nbsp; Embed2.set_image(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; Embed2.set_thumbnail(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; Embed3 = discord.Embed(title="Title", description="Description", color=0x000000)&nbsp; &nbsp; Embed3.set_image(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; Embed3.set_thumbnail(url="https://external-preview.redd.it/mu4xWSMFJroZUimyZY4vvjloaAnmzXTh1O2QI_TFlzc.jpg?width=960&crop=smart&auto=webp&s=e042f61d74a80c4bf3f170b9628c14ef56bac427")&nbsp; &nbsp; embeds = [Embed1, Embed2, Embed3]&nbsp; &nbsp; paginator = BotEmbedPaginator(ctx, embeds)&nbsp; &nbsp; await paginator.run()
随时随地看视频慕课网APP

相关分类

Python
我要回答