mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Upgrading views manager in messages timeout
This commit is contained in:
@@ -16,18 +16,25 @@ class BasicView(View, AbstractView):
|
||||
super().__init__(timeout=timeout)
|
||||
self.__bot = bot
|
||||
self.__message: Message = None
|
||||
self.__working = True
|
||||
|
||||
for button in buttons:
|
||||
# Set the buttons to have a instance of the view that contains them
|
||||
button.set_view(self)
|
||||
self.add_item(button)
|
||||
|
||||
def stopView(self):
|
||||
self.__working = False
|
||||
|
||||
async def on_timeout(self) -> None:
|
||||
# Disable all itens and, if has the message, edit it
|
||||
try:
|
||||
if not self.__working:
|
||||
return
|
||||
|
||||
self.disable_all_items()
|
||||
if self.__message is not None and isinstance(self.__message, Message):
|
||||
await self.__message.edit(view=self)
|
||||
await self.__message.edit(f"{emojis.MUSIC} - The buttons in this message have been disabled due timeout", view=self)
|
||||
except Exception as e:
|
||||
print(f'[ERROR EDITING MESSAGE] -> {e}')
|
||||
|
||||
@@ -35,5 +42,11 @@ class BasicView(View, AbstractView):
|
||||
self.__message = message
|
||||
|
||||
async def update(self):
|
||||
if self.__message is not None:
|
||||
await self.__message.edit(view=self)
|
||||
try:
|
||||
if not self.__working:
|
||||
return
|
||||
|
||||
if self.__message is not None:
|
||||
await self.__message.edit(view=self)
|
||||
except Exception as e:
|
||||
print(f'[ERROR UPDATING MESSAGE] -> {e}')
|
||||
|
||||
Reference in New Issue
Block a user