#Disabling all buttons in a message component

1 messages · Page 1 of 1 (latest)

upbeat shadow
#
    if not find_poll or not find_poll.active:
        for component in interaction.message.components:
            for button in component.children:
                button.disabled = True
        return await interaction.edit_original_message(content="This poll has ended", components=interaction.message.components)
TypeError: `components` must be a `WrappedComponent` or `ActionRow`, a sequence/list of `WrappedComponent`s or `ActionRow`s, or a nested sequence/list of `WrappedComponent`s

Hey. I'm trying to disable all buttons on my embed but getting this error. What is the correct way to do this?

Ideally I'd be able to reuse the component data inside of the interaction object, so i don't need to calculate it all again.

I just need to disable each button but keep the same label etc.

graceful kestrel
#

for interesting reasons, you can’t resend the component received in an interaction

#

i would suggest using either

#

-d View.from_message

main hedgeBOT
#

classmethod from_message(message, /, *, timeout=180.0)```
Converts a message’s components into a [`View`](https://docs.disnake.dev/page/api.html#disnake.ui.View "disnake.ui.View").

The [`Message.components`](https://docs.disnake.dev/page/api.html#disnake.Message.components "disnake.Message.components") of a message are read-only and separate types from those in the `disnake.ui` namespace. In order to modify and edit message components they must be converted into a [`View`](https://docs.disnake.dev/page/api.html#disnake.ui.View "disnake.ui.View") first.
graceful kestrel
#

-d ActionRow.from_message

main hedgeBOT
#

classmethod rows_from_message(message, *, strict=True)```
Create a list of up to 5 action rows from the components on an existing message.

This will abide by existing component format on the message, including component ordering and rows. Components will be transformed to UI kit components, such that they can be easily modified and re-sent as action rows.

New in version 2.6.
upbeat shadow
#

Thanks! Do you happen to know why you can't resend the component?

#

ActionRow.from_message resolved my problem though, thanks 🙂

dense steeple
#

(same for all other components)

#

the former is returned by the api and cannot be sent, the latter is what users make and put on e.g. a view.

#

as for why it was made that way instead of unified into one, I have no idea. This happened before disnake was forked from dpy, hence it's still in the lib

graceful kestrel
#

couldn’t we just transform the returned components

dense steeple
#

as far as I'm concerned, both flavours should just be allowed in sending

#

ui.Button specifically caters to views, as for the rest there's not really any difference

#

I have some plans to rework components a bit, but it's a bit of a massive undertaking

graceful kestrel
#

yea makes sense