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

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

Scrolling down in a discord.py embed

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...