mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Adding types and changing some messages from class
This commit is contained in:
@@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
|
||||
from typing import List
|
||||
from discord.ext.commands import Context
|
||||
from discord import Client, Guild, ClientUser, Member
|
||||
from Config.Messages import Messages
|
||||
from Controllers.PlayerController import PlayersController
|
||||
from Music.Player import Player
|
||||
from Controllers.ControllerResponse import ControllerResponse
|
||||
@@ -19,6 +20,7 @@ class AbstractController(ABC):
|
||||
self.__ctx: Context = ctx
|
||||
self.__bot_user: ClientUser = self.__bot.user
|
||||
self.__id = self.__bot_user.id
|
||||
self.__messages = Messages()
|
||||
self.__config = Configs()
|
||||
self.__helper = Helper()
|
||||
self.__embeds = Embeds()
|
||||
@@ -60,6 +62,10 @@ class AbstractController(ABC):
|
||||
def config(self) -> Configs:
|
||||
return self.__config
|
||||
|
||||
@property
|
||||
def messages(self) -> Messages:
|
||||
return self.__messages
|
||||
|
||||
@property
|
||||
def helper(self) -> Helper:
|
||||
return self.__helper
|
||||
|
||||
@@ -13,7 +13,7 @@ class HistoryController(AbstractController):
|
||||
history = self.player.playlist.songs_history
|
||||
|
||||
if len(history) == 0:
|
||||
text = self.config.HISTORY_EMPTY
|
||||
text = self.messages.HISTORY_EMPTY
|
||||
|
||||
else:
|
||||
text = f'\n📜 History Length: {len(history)} | Max: {self.config.MAX_SONGS_HISTORY}\n'
|
||||
|
||||
@@ -10,7 +10,7 @@ class LoopController(AbstractController):
|
||||
super().__init__(ctx, bot)
|
||||
|
||||
async def run(self, args: str) -> ControllerResponse:
|
||||
if args == '' or args == None:
|
||||
if args == '' or args is None:
|
||||
self.player.playlist.loop_all()
|
||||
embed = self.embeds.LOOP_ALL_ACTIVATED()
|
||||
return ControllerResponse(self.ctx, embed)
|
||||
|
||||
@@ -49,7 +49,7 @@ class MoveController(AbstractController):
|
||||
pos1 = int(pos1)
|
||||
pos2 = int(pos2)
|
||||
except:
|
||||
return NumberRequired(self.config.ERROR_NUMBER)
|
||||
return NumberRequired(self.messages.ERROR_NUMBER)
|
||||
|
||||
def __sanitize_input(self, pos1: int, pos2: int) -> tuple:
|
||||
pos1 = int(pos1)
|
||||
|
||||
@@ -2,11 +2,13 @@ from discord.ext.commands import Context
|
||||
from discord import Client
|
||||
from Controllers.AbstractController import AbstractController
|
||||
from Controllers.ControllerResponse import ControllerResponse
|
||||
from Utils.Cleaner import Cleaner
|
||||
|
||||
|
||||
class NowPlayingController(AbstractController):
|
||||
def __init__(self, ctx: Context, bot: Client) -> None:
|
||||
super().__init__(ctx, bot)
|
||||
self.__cleaner = Cleaner()
|
||||
|
||||
async def run(self) -> ControllerResponse:
|
||||
if not self.player.playing:
|
||||
@@ -14,9 +16,10 @@ class NowPlayingController(AbstractController):
|
||||
return ControllerResponse(self.ctx, embed)
|
||||
|
||||
if self.player.playlist.looping_one:
|
||||
title = self.config.ONE_SONG_LOOPING
|
||||
title = self.messages.ONE_SONG_LOOPING
|
||||
else:
|
||||
title = self.config.SONG_PLAYING
|
||||
title = self.messages.SONG_PLAYING
|
||||
await self.__cleaner.clean_messages(self.ctx, self.config.CLEANER_MESSAGES_QUANT)
|
||||
|
||||
info = self.player.playlist.current.info
|
||||
embed = self.embeds.SONG_INFO(info, title)
|
||||
|
||||
@@ -25,9 +25,9 @@ class QueueController(AbstractController):
|
||||
await self.__down.preload(songs_preload)
|
||||
|
||||
if self.player.playlist.looping_all:
|
||||
title = self.config.ALL_SONGS_LOOPING
|
||||
title = self.messages.ALL_SONGS_LOOPING
|
||||
else:
|
||||
title = self.config.QUEUE_TITLE
|
||||
title = self.messages.QUEUE_TITLE
|
||||
|
||||
total_time = Utils.format_time(sum([int(song.duration if song.duration else 0)
|
||||
for song in songs_preload]))
|
||||
@@ -36,7 +36,7 @@ class QueueController(AbstractController):
|
||||
text = f'📜 Queue length: {total_songs} | ⌛ Duration: `{total_time}` downloaded \n\n'
|
||||
|
||||
for pos, song in enumerate(songs_preload, start=1):
|
||||
song_name = song.title if song.title else self.config.SONG_DOWNLOADING
|
||||
song_name = song.title if song.title else self.messages.SONG_DOWNLOADING
|
||||
text += f"**`{pos}` - ** {song_name} - `{Utils.format_time(song.duration)}`\n"
|
||||
|
||||
embed = self.embeds.QUEUE(title, text)
|
||||
|
||||
@@ -42,7 +42,7 @@ class RemoveController(AbstractController):
|
||||
try:
|
||||
position = int(position)
|
||||
except:
|
||||
return NumberRequired(self.config.ERROR_NUMBER)
|
||||
return NumberRequired(self.messages.ERROR_NUMBER)
|
||||
|
||||
def __sanitize_input(self, position: str) -> int:
|
||||
position = int(position)
|
||||
|
||||
Reference in New Issue
Block a user