mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Changing View in Queue message and creating new handler to jump to music
This commit is contained in:
10
UI/Views/AbstractView.py
Normal file
10
UI/Views/AbstractView.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class AbstractView(ABC):
|
||||
@abstractmethod
|
||||
async def update(self) -> None:
|
||||
pass
|
||||
|
||||
def set_message(self, message) -> None:
|
||||
pass
|
||||
@@ -1,21 +1,25 @@
|
||||
from typing import List
|
||||
from discord import Button, Message
|
||||
from discord import Message
|
||||
from discord.ui import View
|
||||
from Config.Emojis import VEmojis
|
||||
from Music.VulkanBot import VulkanBot
|
||||
from UI.Views.AbstractView import AbstractView
|
||||
from UI.Buttons.AbstractItem import AbstractItem
|
||||
|
||||
emojis = VEmojis()
|
||||
|
||||
|
||||
class BasicView(View):
|
||||
class BasicView(View, AbstractView):
|
||||
"""View that receives buttons to hold, in timeout disable buttons"""
|
||||
|
||||
def __init__(self, bot: VulkanBot, buttons: List[Button], timeout: float = 6000):
|
||||
def __init__(self, bot: VulkanBot, buttons: List[AbstractItem], timeout: float = 6000):
|
||||
super().__init__(timeout=timeout)
|
||||
self.__bot = bot
|
||||
self.__message: Message = None
|
||||
|
||||
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)
|
||||
|
||||
async def on_timeout(self) -> None:
|
||||
@@ -29,3 +33,7 @@ class BasicView(View):
|
||||
|
||||
def set_message(self, message: Message) -> None:
|
||||
self.__message = message
|
||||
|
||||
async def update(self):
|
||||
if self.__message is not None:
|
||||
await self.__message.edit(view=self)
|
||||
|
||||
Reference in New Issue
Block a user