mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Creating Player View
This commit is contained in:
@@ -5,7 +5,7 @@ from discord import Message
|
||||
from Music.VulkanBot import VulkanBot
|
||||
|
||||
|
||||
class AbstractView(ABC):
|
||||
class AbstractCommandResponse(ABC):
|
||||
def __init__(self, response: HandlerResponse) -> None:
|
||||
self.__response: HandlerResponse = response
|
||||
self.__context: Context = response.ctx
|
||||
@@ -1,8 +1,8 @@
|
||||
from Views.AbstractView import AbstractView
|
||||
from Views.AbstractCogResponse import AbstractCommandResponse
|
||||
from Handlers.HandlerResponse import HandlerResponse
|
||||
|
||||
|
||||
class EmbedView(AbstractView):
|
||||
class EmbedCommandResponse(AbstractCommandResponse):
|
||||
def __init__(self, response: HandlerResponse) -> None:
|
||||
super().__init__(response)
|
||||
|
||||
357
Views/Embeds.py
357
Views/Embeds.py
@@ -1,357 +0,0 @@
|
||||
from Config.Messages import Messages
|
||||
from Config.Exceptions import VulkanError
|
||||
from discord import Embed
|
||||
from Config.Configs import Configs
|
||||
from Config.Colors import Colors
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class Embeds:
|
||||
def __init__(self) -> None:
|
||||
self.__config = Configs()
|
||||
self.__messages = Messages()
|
||||
self.__colors = Colors()
|
||||
|
||||
def ONE_SONG_LOOPING(self, info: dict) -> Embed:
|
||||
title = self.__messages.ONE_SONG_LOOPING
|
||||
return self.SONG_INFO(info, title)
|
||||
|
||||
def EMPTY_QUEUE(self) -> Embed:
|
||||
title = self.__messages.SONG_PLAYER
|
||||
text = self.__messages.EMPTY_QUEUE
|
||||
embed = Embed(
|
||||
title=title,
|
||||
description=text,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def MISSING_ARGUMENTS(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.ERROR_MISSING_ARGUMENTS,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def SONG_ADDED_TWO(self, info: dict, pos: int) -> Embed:
|
||||
embed = self.SONG_INFO(info, self.__messages.SONG_ADDED_TWO, pos)
|
||||
return embed
|
||||
|
||||
def INVALID_INPUT(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.INVALID_INPUT,
|
||||
colour=self.__colors.BLACK)
|
||||
return embed
|
||||
|
||||
def UNAVAILABLE_VIDEO(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.VIDEO_UNAVAILABLE,
|
||||
colour=self.__colors.BLACK)
|
||||
return embed
|
||||
|
||||
def DOWNLOADING_ERROR(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.DOWNLOADING_ERROR,
|
||||
colour=self.__colors.BLACK)
|
||||
return embed
|
||||
|
||||
def SONG_ADDED(self, title: str) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.SONG_ADDED.format(title),
|
||||
colour=self.__colors.BLUE)
|
||||
return embed
|
||||
|
||||
def SONGS_ADDED(self, quant: int) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.SONGS_ADDED.format(quant),
|
||||
colour=self.__colors.BLUE)
|
||||
return embed
|
||||
|
||||
def SONG_INFO(self, info: dict, title: str, position='Playing Now') -> Embed:
|
||||
embedvc = Embed(
|
||||
title=title,
|
||||
description=f"[{info['title']}]({info['original_url']})",
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
|
||||
embedvc.add_field(name=self.__messages.SONGINFO_UPLOADER,
|
||||
value=info['uploader'],
|
||||
inline=False)
|
||||
|
||||
embedvc.add_field(name=self.__messages.SONGINFO_REQUESTER,
|
||||
value=info['requester'],
|
||||
inline=True)
|
||||
|
||||
if 'thumbnail' in info.keys():
|
||||
embedvc.set_thumbnail(url=info['thumbnail'])
|
||||
|
||||
if 'duration' in info.keys():
|
||||
duration = str(timedelta(seconds=info['duration']))
|
||||
embedvc.add_field(name=self.__messages.SONGINFO_DURATION,
|
||||
value=f"{duration}",
|
||||
inline=True)
|
||||
else:
|
||||
embedvc.add_field(name=self.__messages.SONGINFO_DURATION,
|
||||
value=self.__messages.SONGINFO_UNKNOWN_DURATION,
|
||||
inline=True)
|
||||
|
||||
embedvc.add_field(name=self.__messages.SONGINFO_POSITION,
|
||||
value=position,
|
||||
inline=True)
|
||||
|
||||
return embedvc
|
||||
|
||||
def SONG_MOVED(self, song_name: str, pos1: int, pos2: int) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.SONG_MOVED_SUCCESSFULLY.format(song_name, pos1, pos2),
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def ERROR_MOVING(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.UNKNOWN_ERROR,
|
||||
description=self.__messages.ERROR_MOVING,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def ERROR_EMBED(self, description: str) -> Embed:
|
||||
embed = Embed(
|
||||
description=description,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def CUSTOM_ERROR(self, error: VulkanError) -> Embed:
|
||||
embed = Embed(
|
||||
title=error.title,
|
||||
description=error.message,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def WRONG_LENGTH_INPUT(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.BAD_COMMAND_TITLE,
|
||||
description=self.__messages.LENGTH_ERROR,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def BAD_LOOP_USE(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.BAD_COMMAND_TITLE,
|
||||
description=self.__messages.BAD_USE_OF_LOOP,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def COMMAND_ERROR(self):
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.ERROR_MISSING_ARGUMENTS,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def COMMAND_NOT_FOUND(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.COMMAND_NOT_FOUND_TITLE,
|
||||
description=self.__messages.COMMAND_NOT_FOUND,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def MY_ERROR_BAD_COMMAND(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.BAD_COMMAND_TITLE,
|
||||
description=self.__messages.BAD_COMMAND,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def UNKNOWN_ERROR(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.UNKNOWN_ERROR,
|
||||
colour=self.__colors.RED
|
||||
)
|
||||
return embed
|
||||
|
||||
def FAIL_DUE_TO_LOOP_ON(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.LOOP_ON,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def ERROR_SHUFFLING(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.ERROR_SHUFFLING,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def SONGS_SHUFFLED(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.SONGS_SHUFFLED,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def LOOP_ONE_ACTIVATED(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.LOOP_ONE_ACTIVATE,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def LOOP_ALL_ACTIVATED(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.LOOP_ALL_ACTIVATE,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def SONG_PROBLEMATIC(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.DOWNLOADING_ERROR,
|
||||
colour=self.__colors.BLACK)
|
||||
return embed
|
||||
|
||||
def PLAYER_RESTARTED(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
description=self.__messages.ERROR_IN_PROCESS,
|
||||
colour=self.__colors.BLACK)
|
||||
return embed
|
||||
|
||||
def NO_CHANNEL(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.IMPOSSIBLE_MOVE,
|
||||
description=self.__messages.NO_CHANNEL,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def ERROR_DUE_LOOP_ONE_ON(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.BAD_COMMAND_TITLE,
|
||||
description=self.__messages.ERROR_DUE_LOOP_ONE_ON,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def LOOP_DISABLE(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.LOOP_DISABLE,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def NOT_PREVIOUS_SONG(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.NOT_PREVIOUS,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def HISTORY(self, description: str) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.HISTORY_TITLE,
|
||||
description=description,
|
||||
colour=self.__colors.BLUE)
|
||||
return embed
|
||||
|
||||
def NOT_PLAYING(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.SONG_PLAYER,
|
||||
description=self.__messages.PLAYER_NOT_PLAYING,
|
||||
colour=self.__colors.BLUE)
|
||||
return embed
|
||||
|
||||
def QUEUE(self, title: str, description: str) -> Embed:
|
||||
embed = Embed(
|
||||
title=title,
|
||||
description=description,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def INVITE(self, bot_id: str) -> Embed:
|
||||
link = self.__messages.INVITE_URL
|
||||
link.format(bot_id)
|
||||
text = self.__messages.INVITE_MESSAGE.format(link, link)
|
||||
|
||||
embed = Embed(
|
||||
title="Invite Vulkan",
|
||||
description=text,
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def ERROR_NUMBER(self) -> Embed:
|
||||
embed = Embed(
|
||||
description=self.__messages.ERROR_NUMBER,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def RANDOM_NUMBER(self, a: int, b: int, x: int) -> Embed:
|
||||
embed = Embed(
|
||||
title=f'Random number between [{a}, {b}]',
|
||||
description=x,
|
||||
colour=self.__colors.GREEN
|
||||
)
|
||||
return embed
|
||||
|
||||
def SONG_REMOVED(self, song_name: str) -> Embed:
|
||||
embed = Embed(
|
||||
description=self.__messages.SONG_REMOVED_SUCCESSFULLY.format(song_name),
|
||||
colour=self.__colors.BLUE
|
||||
)
|
||||
return embed
|
||||
|
||||
def PLAYLIST_RANGE_ERROR(self) -> Embed:
|
||||
embed = Embed(
|
||||
description=self.__messages.LENGTH_ERROR,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
def CARA_COROA(self, result: str) -> Embed:
|
||||
embed = Embed(
|
||||
title='Cara Coroa',
|
||||
description=f'Result: {result}',
|
||||
colour=self.__colors.GREEN
|
||||
)
|
||||
return embed
|
||||
|
||||
def CHOSEN_THING(self, thing: str) -> Embed:
|
||||
embed = Embed(
|
||||
title='Choose something',
|
||||
description=f'Chosen: {thing}',
|
||||
colour=self.__colors.GREEN
|
||||
)
|
||||
return embed
|
||||
|
||||
def BAD_CHOOSE_USE(self) -> Embed:
|
||||
embed = Embed(
|
||||
title='Choose something',
|
||||
description=f'Error: Use {self.__config.BOT_PREFIX}help choose to understand this command.',
|
||||
colour=self.__colors.RED
|
||||
)
|
||||
return embed
|
||||
16
Views/EmoteCogResponse.py
Normal file
16
Views/EmoteCogResponse.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from Config.Emojis import VEmojis
|
||||
from Views.AbstractCogResponse import AbstractCommandResponse
|
||||
from Handlers.HandlerResponse import HandlerResponse
|
||||
|
||||
|
||||
class EmoteCommandResponse(AbstractCommandResponse):
|
||||
|
||||
def __init__(self, response: HandlerResponse) -> None:
|
||||
super().__init__(response)
|
||||
self.__emojis = VEmojis()
|
||||
|
||||
async def run(self) -> None:
|
||||
if self.response.success:
|
||||
await self.message.add_reaction(self.__emojis.SUCCESS)
|
||||
else:
|
||||
await self.message.add_reaction(self.__emojis.ERROR)
|
||||
@@ -1,14 +0,0 @@
|
||||
from Views.AbstractView import AbstractView
|
||||
from Handlers.HandlerResponse import HandlerResponse
|
||||
|
||||
|
||||
class EmoteView(AbstractView):
|
||||
|
||||
def __init__(self, response: HandlerResponse) -> None:
|
||||
super().__init__(response)
|
||||
|
||||
async def run(self) -> None:
|
||||
if self.response.success:
|
||||
await self.message.add_reaction('✅')
|
||||
else:
|
||||
await self.message.add_reaction('❌')
|
||||
47
Views/PlayerView.py
Normal file
47
Views/PlayerView.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from typing import Optional
|
||||
from discord.ui import View, Button, button
|
||||
from Config.Emojis import VEmojis
|
||||
from discord import Interaction, ButtonStyle
|
||||
|
||||
emojis = VEmojis()
|
||||
|
||||
|
||||
class PlayerView(View):
|
||||
def __init__(self, timeout: Optional[float] = 180):
|
||||
super().__init__(timeout=timeout)
|
||||
|
||||
@button(label="Back", style=ButtonStyle.secondary, emoji=emojis.BACK)
|
||||
async def prevCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Pause", style=ButtonStyle.secondary, emoji=emojis.PAUSE)
|
||||
async def pauseCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Play", style=ButtonStyle.secondary, emoji=emojis.PLAY)
|
||||
async def playCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Stop", style=ButtonStyle.secondary, emoji=emojis.STOP)
|
||||
async def stopCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Skip", style=ButtonStyle.secondary, emoji=emojis.SKIP)
|
||||
async def skipCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Songs", style=ButtonStyle.secondary, emoji=emojis.QUEUE)
|
||||
async def songsCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Loop Off", style=ButtonStyle.grey, emoji=emojis.LOOP_OFF)
|
||||
async def loopOffCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Loop All", style=ButtonStyle.secondary, emoji=emojis.LOOP_ALL)
|
||||
async def loopAllCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
|
||||
@button(label="Loop One", style=ButtonStyle.secondary, emoji=emojis.LOOP_ONE)
|
||||
async def loopOneCallback(self, button: Button, interaction: Interaction) -> None:
|
||||
await interaction.response.send_message("Hello")
|
||||
Reference in New Issue
Block a user