#๐Ÿ”’ Select menu "resets" after option is chosen

37 messages ยท Page 1 of 1 (latest)

celest gobletBOT
#

@simple fossil

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

simple fossil
#

Python 3.12
my bot developer tells me that in order to update the message, the option that you select from the select menu has to be undone/"reset" (this means that for the user, it looks as if they had NOT selected an option at all). is this true? video attached for context (also for some reason the type of payment schedule is updated within the message but the select menu is still "reset")

the chosen option is updated internally within the database

south iris
simple fossil
south iris
#

Your bot developer should know how to do that

simple fossil
south iris
#

I would like to help you but I don't know what differences there are with my library

#

I think it's the same, do you know Python?

simple fossil
#

i was hoping for an easy fix that i can apply myself because i have limited knowledge

south iris
#

And then edit the message with the new message and the new view

simple fossil
# south iris Tell your developer to just iterate over the current menu options and just compa...
elif "payment_schedule-" in inter.component.custom_id:
            await inter.response.defer()
            selected_option = inter.data['values'][0]

            print(inter.component.options)

            for loopoption in inter.component.options:
                if loopoption.value == selected_option:
                    loopoption.default = True
                else:
                    loopoption.default = False

            identification = (inter.component.custom_id)[len("payment-schedule-"):]

            update_result = self.collection.update_one(
                {"_id": int(identification)}, {"$set": {"schedule": selected_option}}
            )

            data = self.collection.find_one({"_id": int(identification)})

            embed = disnake.Embed(title=data["title"], description=data["description"])
            embed.add_field(name="Payment schedule", value=f"**Schedule:** {data['schedule']}", inline=True)
            embed.add_field(name="Payment methods", value=data["method"], inline=True)
            embed.add_field(name="Contact", value=f"**Discord:** {inter.user.mention}", inline=False)
            embed.set_author(name=f"{inter.user.name} | (ID: {inter.user.id})",
                            icon_url=inter.user.display_avatar.url)
            embed.set_footer(
                text=f"Post ID: {int(identification)} | Approved by XXXX | Posted on: {datetime.date.today().strftime('%d/%m/%Y')}")

            if "attachment" in data:
                embed.set_image(url=data["attachment"])

            await inter.edit_original_message(embed=embed)
#

im doing it, but it's not working it still just goes back to the placeholder

south iris
simple fossil
south iris
simple fossil
south iris
simple fossil
south iris
#

Try this

simple fossil
# south iris `await inter.edit_original_message(embed=embed, view=inter.component.view)`
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\disnake\client.py", line 703, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Downloads\UM\cogs\post.py", line 764, in on_dropdown
    await inter.edit_original_message(embed=embed, view=inter.component.view)
                                                        ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'StringSelectMenu' object has no attribute 'view'
south iris
#

Hmmm a moment

#

Hmmmm, it is very strange

#

OhI think I was wrong lol

simple fossil
south iris
simple fossil
south iris
#

Sorry I'm not a disnake expert and I'm getting tired of the documentation and I don't see a direct way to get the view, you can apply that solution or you can wait for someone experienced in disnake to help you.

celest gobletBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.