我怎样才能制作如图所示的模态 - 不和谐

Aşk*_*MEL 1 python discord discord.py nextcord

我想在按下按钮时创建一个如图所示的模式。如何使用 Discord.py 或 nextcord 制作此模型?

在此输入图像描述

Den*_*er1 6

您可以在此处找到 Nextcord 中的模态示例:

https://github.com/nextcord/nextcord/blob/master/examples/modals/

class Pet(nextcord.ui.Modal):
    def __init__(self):
        super().__init__("Your pet")  # Modal title

        # Create a text input and add it to the modal
        self.name = nextcord.ui.TextInput(
            label="Your pet's name",
            min_length=2,
            max_length=50,
        )
        self.add_item(self.name)

        # Create a long text input and add it to the modal
        self.description = nextcord.ui.TextInput(
            label="Description",
            style=nextcord.TextInputStyle.paragraph,
            placeholder="Information that can help us recognise your pet",
            required=False,
            max_length=1800,
        )
        self.add_item(self.description)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        """This is the function that gets called when the submit button is pressed"""
        response = f"{interaction.user.mention}'s favourite pet's name is {self.name.value}."
        if self.description.value != "":
            response += f"\nTheir pet can be recognized by this information:\n{self.description.value}"
        await interaction.send(response)

@bot.slash_command(
    name="pet",
    description="Describe your favourite pet",
    guild_ids=[TESTING_GUILD_ID],
)
async def send(interaction: nextcord.Interaction):
    # sending the modal on an interaction (can be slash, buttons, or select menus)
    modal = Pet()
    await interaction.response.send_modal(modal)
Run Code Online (Sandbox Code Playgroud)