#is there a way to disable all the current active buttons

1 messages · Page 1 of 1 (latest)

verbal escarp
#

I am making a command "saferestart" which i want to disable all the active buttons and db operations before shutting down the bot. Is there a way to do this via an inbuilt module function

somber elbow
#

For the button you could just use the on_interaction and return a message like bot will restart soon

stiff bramble
#

I think they wanna disable the buttons for the downtime but I don't think this is necessary. Bot restarts are rare and fast enough

verbal escarp
somber elbow
#

Disabling all the button are not possible

#

But using on_interaction to act as they are disable is possible

verbal escarp
#

i see. Thanks !

somber elbow
#

But this will stop every interaction including the current one

#

What I mean by not possible is that you would need to fetch each message with view and disabled them which will raise really quickly some rate limit

tribal condor
stiff bramble
#

Actually wait. What's the idea here
Do you want to disable the buttons permanently, or do you want to re-enable them on restart (i.e. are you using persistent views)

verbal escarp
verbal escarp
tribal condor
#

Do you use persistent views or not ?

verbal escarp
#

no.

tribal condor
#

Ok lemme take a look rq then I'll give you something. But no guarantee that it will keep working when pycord updates

verbal escarp
#

Thanks !!

stiff bramble
#

Unless Paillat finds smth I'd do it like Luma said
listen to on_interaction and send a response telling them to re-use whatever command caused that view, or whatever
And optionally fetch the message and disable the button, i don't think this would run you into any ratelimit as i doubt it happens that frequently

verbal escarp
#

that's also a good solution

tribal condor
#
    async def shutdown(bot: discord.Bot):
        for message_id, view in bot._connection._view_store._synced_message_views.items():
            if view.is_persistent():
                continue
            view.disable_all_items()
            target = view.parent or view.message
            if not target:
                continue
            try:
                await target.edit(view=view)
            except discord.HTTPException:
                logging.exception("Failed to disable view for message ID %d", message_id)

#

Try this

stiff bramble
#

chained private attribute calls, fun

tribal condor
#

🫠

verbal escarp
#

intresting

#

let me try this rq

#

Ayeeee !! it worked

#

thanks a ton !!

tribal condor
#

.tag close

somber charmBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @daring dome.

somber elbow
tribal condor
#

It would