#๐ Select menu "resets" after option is chosen
37 messages ยท Page 1 of 1 (latest)
@simple fossil
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.
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
I already answered your question in #discord-bots
how would i go about doing that? i dont quite see how to do that https://pastebin.com/66GVNYbT
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm not sure how that is done in Disnake because I use another library. But it is possible to update the menu and message when the user interacts with the menu
Your bot developer should know how to do that

he literally said this ๐ญ
Bruh
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?
no that's why i hired someone to make this bot for me ๐ญ
i was hoping for an easy fix that i can apply myself because i have limited knowledge
Tell your developer to just iterate over the current menu options and just compare the values of each to the option selected by the user.
And you should change the default attribute to True and the other options to False
And then edit the message with the new message and the new view
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
is that you are only updating the embed message but not the View
i honestly dont know im trying to update the select menu itself
Give me a moment, look at the documentation
ite lmk once you find something
Ok I think I found something
what is it ?
await inter.edit_original_message(embed=embed, view=inter.component.view)
Try this
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'
๐ญ
I can't figure out how to get the component view. You can create a new view and add the modified menu
the existing menu needs to be gone and then replaced by the new menu ig?
For now yes, you must modify the message with the new view and the new embed message.
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.
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.