0

Basically the interaction is just an echec as you can see here

my code:

import disnake
from disnake import Intents
from disnake.ext.commands import Context, Bot



bot = Bot(command_prefix='+', test_guilds=[1032280589031706706], help_command=None, intents=Intents.all())

@bot.event
async def on_ready():
    print('ready')
    
@bot.command()
async def test(ctx: Context):
    view = DropdownView()
    await ctx.send(embed=disnake.Embed(description='>\n '), view=view)



class Dropdown(disnake.ui.Select):
    def __init__(self):
        self.Embedtitle = None
        self.Embeddescription = '>\n'
        
        
        options = [
            disnake.SelectOption(
                label="Red", description="Your favourite colour is red", emoji=""
            ),
            disnake.SelectOption(
                label="Green", description="Your favourite colour is green", emoji=""
            ),
            disnake.SelectOption(
                label="Blue", description="Your favourite colour is blue", emoji=""
            ),
        ]

        # The placeholder is what will be shown when no option is chosen.
        # The min and max values indicate we can only pick one of the three options.
        # The options parameter defines the dropdown options, see above.
        super().__init__(
            placeholder="Choose your favourite colour...",
            min_values=1,
            max_values=1,
            options=options,
        )

    async def callback(self, inter: disnake.MessageInteraction):
        print(f"Your favourite colour is {self.values[0]}")
        def check(m:disnake.Message):
            return inter.author.id == m.author.id and m.content != ''
        msg = await bot.wait_for('message', check=check, timeout=120.0)
        self.Embeddescription=msg
        await inter.response.edit_message(embed=disnake.Embed(
            colour=None,
            title=self.Embedtitle,
            description=self.Embeddescription,
            ))


class DropdownView(disnake.ui.View):
    def __init__(self):
        super().__init__()

        # Add the dropdown to our view object.
        self.add_item(Dropdown())

bot.run("token")

The code come from official disnake repo because i first thought my code has a problem, but after some testing i now know the interation is an echec because of bot.wait_for()

I try to make an embed editor bot,

you type the command +embed and the bot return an embed, you can select item in a Select menu to edit description, footer, etc.. of the embed and send it in a channel.

Exemple:
The bot send an empty Embed to preview the embed that will be send when we have finish,
we can choose what to edit (description, title, author, field, etc..)
and when we choose what to edit, the bot just prompt for it like

`What will be the description`

and we send a message that contain the description

i'm trying to make the bot prompt the new description/title/author/etc.. with bot.wait_for() but it seems to not work at all, any solution ?

majvax
  • 1
  • 1

1 Answers1

0

I fix the problem by simply call

await inter.response.defer()

right after the callback function.

majvax
  • 1
  • 1