Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is my embed rn

It uses the google API to get upcoming events on a calendar but I have to limit the number of events it gets since the message will be too long. The list of calendars is stored in the description of the embed. Is there any way to limit the embed to a certain size and be able to scroll down in the description so all events can be displayed?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

As Zimano said, you can't have scrollable elements in embeds, but what you can do is a multi-page embed, the easiest approach would be with ext.menus (To install it: python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus)

import discord
from discord.ext import menus

class MultiPageEmbed(menus.ListPageSource):
    async def format_page(self, menu, entry):
        return entry


@bot.command()
async def whatever(ctx):
    # Put all your embeds here
    embeds = [discord.Embed(title="Embed 1"), discord.Embed(title="Embed 2"), discord.Embed(title="Embed 3")]

    menu = menus.MenuPages(MultiPageEmbed(embeds, per_page=1))
    await menu.start(ctx)

Unfornatelly it's still in beta so there's no docs about it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...