mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Chaging config and help to class
This commit is contained in:
51
config/Helper.py
Normal file
51
config/Helper.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
from config.Singleton import Singleton
|
||||||
|
from config.Config import Config
|
||||||
|
|
||||||
|
|
||||||
|
class Helper(Singleton):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
if not super().created:
|
||||||
|
config = Config()
|
||||||
|
self.HELP_SKIP = 'Skip the current playing song.'
|
||||||
|
self.HELP_SKIP_LONG = 'Skip the playing of the current song, does not work if loop one is activated. \n\nArguments: None.'
|
||||||
|
self.HELP_RESUME = 'Resumes the song player.'
|
||||||
|
self.HELP_RESUME_LONG = 'If the player if paused, return the playing. \n\nArguments: None.'
|
||||||
|
self.HELP_CLEAR = 'Clear the queue and songs history.'
|
||||||
|
self.HELP_CLEAR_LONG = 'Clear the songs queue and songs history. \n\nArguments: None.'
|
||||||
|
self.HELP_STOP = 'Stop the song player.'
|
||||||
|
self.HELP_STOP_LONG = 'Stop the song player, clear queue and history and remove Vulkan from voice channel.\n\nArguments: None.'
|
||||||
|
self.HELP_LOOP = 'Control the loop of songs.'
|
||||||
|
self.HELP_LOOP_LONG = """Control the loop of songs.\n\n Require: A song being played.\nArguments:
|
||||||
|
One - Start looping the current song.
|
||||||
|
All - Start looping all songs in queue.
|
||||||
|
Off - Disable loop."""
|
||||||
|
self.HELP_NP = 'Show the info of the current song.'
|
||||||
|
self.HELP_NP_LONG = 'Show the information of the song being played.\n\nRequire: A song being played.\nArguments: None.'
|
||||||
|
self.HELP_QUEUE = f'Show the first {config.MAX_PRELOAD_SONGS} songs in queue.'
|
||||||
|
self.HELP_QUEUE_LONG = f'Show the first {config.MAX_PRELOAD_SONGS} song in the queue.\n\nArguments: None.'
|
||||||
|
self.HELP_PAUSE = 'Pauses the song player.'
|
||||||
|
self.HELP_PAUSE_LONG = 'If playing, pauses the song player.\n\nArguments: None'
|
||||||
|
self.HELP_PREV = 'Play the previous song.'
|
||||||
|
self.HELP_PREV_LONG = 'Play the previous song. If playing, the current song will return to queue.\n\nRequire: Loop to be disable.\nArguments: None.'
|
||||||
|
self.HELP_SHUFFLE = 'Shuffle the songs playing.'
|
||||||
|
self.HELP_SHUFFLE_LONG = 'Randomly shuffle the songs in the queue.\n\nArguments: None.'
|
||||||
|
self.HELP_PLAY = 'Plays a song.'
|
||||||
|
self.HELP_PLAY_LONG = 'Play a song in discord. \n\nRequire: You to be connected to a voice channel.\nArguments: Youtube or Spotify song/playlist link or the title of the song to be searched in Youtube.'
|
||||||
|
self.HELP_HISTORY = f'Show the history of played songs.'
|
||||||
|
self.HELP_HISTORY_LONG = f'Show the last {config.MAX_SONGS_HISTORY} played songs'
|
||||||
|
self.HELP_MOVE = 'Moves a song from position x to y in queue.'
|
||||||
|
self.HELP_MOVE_LONG = 'Moves a song from position x to position y in queue.\n\nRequire: Positions to be both valid numbers.\nArguments: 1º Number => Initial position, 2º Number => Destination position. Both numbers could be -1 to refer to the last song in queue.\nDefault: By default, if the second number is not passed, it will be 1, moving the selected song to 1º position.'
|
||||||
|
self.HELP_REMOVE = 'Remove a song in position x.'
|
||||||
|
self.HELP_REMOVE_LONG = 'Remove a song from queue in the position passed.\n\nRequire: Position to be a valid number.\nArguments: 1º self.Number => Position in queue of the song.'
|
||||||
|
self.HELP_RESET = 'Reset the Player of the server.'
|
||||||
|
self.HELP_RESET_LONG = 'Reset the Player of the server. Recommended if you find any type of error.\n\nArguments: None'
|
||||||
|
self.HELP_HELP = f'Use {config.BOT_PREFIX}help "command" for more info.'
|
||||||
|
self.HELP_HELP_LONG = f'Use {config.BOT_PREFIX}help command for more info about the command selected.'
|
||||||
|
self.HELP_INVITE = 'Send the invite URL to call Vulkan to your server.'
|
||||||
|
self.HELP_INVITE_LONG = 'Send an message in text channel with a URL to be used to invite Vulkan to your own server.\n\nArguments: None.'
|
||||||
|
self.HELP_RANDOM = 'Return a random number between 1 and x.'
|
||||||
|
self.HELP_RANDOM_LONG = 'Send a randomly selected number between 1 and the number you pass.\n\nRequired: Number to be a valid number.\nArguments: 1º Any number to be used as range.'
|
||||||
|
self.HELP_CHOOSE = 'Choose randomly one item passed.'
|
||||||
|
self.HELP_CHOOSE_LONG = 'Choose randomly one item passed in this command.\n\nRequire: Itens to be separated by comma.\nArguments: As much as you want.'
|
||||||
|
self.HELP_CARA = 'Return cara or coroa.'
|
||||||
|
self.HELP_CARA_LONG = 'Return cara or coroa.'
|
||||||
141
config/config.py
141
config/config.py
@@ -1,82 +1,87 @@
|
|||||||
from decouple import config
|
from decouple import config
|
||||||
|
from config.Singleton import Singleton
|
||||||
|
|
||||||
BOT_TOKEN = config('BOT_TOKEN')
|
|
||||||
SPOTIFY_ID = config('SPOTIFY_ID')
|
|
||||||
SPOTIFY_SECRET = config('SPOTIFY_SECRET')
|
|
||||||
|
|
||||||
BOT_PREFIX = '$'
|
class Config(Singleton):
|
||||||
VC_TIMEOUT = 600
|
def __init__(self) -> None:
|
||||||
|
if not super().created:
|
||||||
|
self.BOT_TOKEN = config('BOT_TOKEN')
|
||||||
|
self.SPOTIFY_ID = config('SPOTIFY_ID')
|
||||||
|
self.SPOTIFY_SECRET = config('SPOTIFY_SECRET')
|
||||||
|
|
||||||
STARTUP_MESSAGE = 'Starting Vulkan...'
|
self.BOT_PREFIX = '$'
|
||||||
STARTUP_COMPLETE_MESSAGE = 'Vulkan is now operating.'
|
self.VC_TIMEOUT = 600
|
||||||
|
|
||||||
MAX_PLAYLIST_LENGTH = 50
|
self.STARTUP_MESSAGE = 'Starting Vulkan...'
|
||||||
MAX_PRELOAD_SONGS = 10
|
self.STARTUP_COMPLETE_MESSAGE = 'Vulkan is now operating.'
|
||||||
MAX_SONGS_HISTORY = 15
|
|
||||||
|
|
||||||
INVITE_MESSAGE = 'To invite Vulkan to your own server, click [here]({})'
|
self.MAX_PLAYLIST_LENGTH = 50
|
||||||
|
self.MAX_PRELOAD_SONGS = 10
|
||||||
|
self.MAX_SONGS_HISTORY = 15
|
||||||
|
|
||||||
SONGINFO_UPLOADER = "Uploader: "
|
self.INVITE_MESSAGE = 'To invite Vulkan to your own server, click [here]({})'
|
||||||
SONGINFO_DURATION = "Duration: "
|
|
||||||
SONGINFO_REQUESTER = 'Requester: '
|
|
||||||
SONGINFO_POSITION = 'Position: '
|
|
||||||
|
|
||||||
SONGS_ADDED = 'You added {} songs to the queue'
|
self.SONGINFO_UPLOADER = "Uploader: "
|
||||||
SONG_ADDED = 'You added the song `{}` to the queue'
|
self.SONGINFO_DURATION = "Duration: "
|
||||||
SONG_ADDED_TWO = '🎧 Song added to the queue'
|
self.SONGINFO_REQUESTER = 'Requester: '
|
||||||
SONG_PLAYING = '🎧 Song playing now'
|
self.SONGINFO_POSITION = 'Position: '
|
||||||
SONG_PLAYER = '🎧 Song Player'
|
|
||||||
QUEUE_TITLE = '🎧 Songs in Queue'
|
|
||||||
ONE_SONG_LOOPING = '🎧 Looping One Song'
|
|
||||||
ALL_SONGS_LOOPING = '🎧 Looping All Songs'
|
|
||||||
SONG_PAUSED = '⏸️ Song paused'
|
|
||||||
SONG_RESUMED = '▶️ Song playing'
|
|
||||||
EMPTY_QUEUE = f'📜 Song queue is empty, use {BOT_PREFIX}play to add new songs'
|
|
||||||
SONG_DOWNLOADING = '📥 Downloading...'
|
|
||||||
|
|
||||||
HISTORY_TITLE = '🎧 Played Songs'
|
self.SONGS_ADDED = 'You added {} songs to the queue'
|
||||||
HISTORY_EMPTY = '📜 There is no musics in history'
|
self.SONG_ADDED = 'You added the song `{}` to the queue'
|
||||||
|
self.SONG_ADDED_TWO = '🎧 Song added to the queue'
|
||||||
|
self.SONG_PLAYING = '🎧 Song playing now'
|
||||||
|
self.SONG_PLAYER = '🎧 Song Player'
|
||||||
|
self.QUEUE_TITLE = '🎧 Songs in Queue'
|
||||||
|
self.ONE_SONG_LOOPING = '🎧 Looping One Song'
|
||||||
|
self.ALL_SONGS_LOOPING = '🎧 Looping All Songs'
|
||||||
|
self.SONG_PAUSED = '⏸️ Song paused'
|
||||||
|
self.SONG_RESUMED = '▶️ Song playing'
|
||||||
|
self.EMPTY_QUEUE = f'📜 Song queue is empty, use {self.BOT_PREFIX}play to add new songs'
|
||||||
|
self.SONG_DOWNLOADING = '📥 Downloading...'
|
||||||
|
|
||||||
SONG_MOVED_SUCCESSFULLY = 'Song `{}` in position `{}` moved to the position `{}` successfully'
|
self.HISTORY_TITLE = '🎧 Played Songs'
|
||||||
SONG_REMOVED_SUCCESSFULLY = 'Song `{}` removed successfully'
|
self.HISTORY_EMPTY = '📜 There is no musics in history'
|
||||||
|
|
||||||
LOOP_ALL_ON = f'❌ Vulkan is looping all songs, use {BOT_PREFIX}loop off to disable this loop first'
|
self.SONG_MOVED_SUCCESSFULLY = 'Song `{}` in position `{}` moved to the position `{}` successfully'
|
||||||
LOOP_ONE_ON = f'❌ Vulkan is looping one song, use {BOT_PREFIX}loop off to disable this loop first'
|
self.SONG_REMOVED_SUCCESSFULLY = 'Song `{}` removed successfully'
|
||||||
LOOP_ALL_ALREADY_ON = '🔁 Vulkan is already looping all songs'
|
|
||||||
LOOP_ONE_ALREADY_ON = '🔂 Vulkan is already looping the current song'
|
|
||||||
LOOP_ALL_ACTIVATE = '🔁 Looping all songs'
|
|
||||||
LOOP_ONE_ACTIVATE = '🔂 Looping the current song'
|
|
||||||
LOOP_DISABLE = '➡️ Loop disabled'
|
|
||||||
LOOP_ALREADY_DISABLE = '❌ Loop is already disabled'
|
|
||||||
LOOP_ON = f'❌ This command cannot be invoked with any loop activated. Use {BOT_PREFIX}loop off to disable loop'
|
|
||||||
|
|
||||||
SONGS_SHUFFLED = '🔀 Songs shuffled successfully'
|
self.LOOP_ALL_ON = f'❌ Vulkan is looping all songs, use {self.BOT_PREFIX}loop off to disable this loop first'
|
||||||
ERROR_SHUFFLING = '❌ Error while shuffling the songs'
|
self.LOOP_ONE_ON = f'❌ Vulkan is looping one song, use {self.BOT_PREFIX}loop off to disable this loop first'
|
||||||
ERROR_MOVING = '❌ Error while moving the songs'
|
self.LOOP_ALL_ALREADY_ON = '🔁 Vulkan is already looping all songs'
|
||||||
LENGTH_ERROR = '❌ Numbers must be between 1 and queue length, use -1 for the last song'
|
self.LOOP_ONE_ALREADY_ON = '🔂 Vulkan is already looping the current song'
|
||||||
ERROR_NUMBER = '❌ This command require a number'
|
self.LOOP_ALL_ACTIVATE = '🔁 Looping all songs'
|
||||||
ERROR_PLAYING = '❌ Error while playing songs'
|
self.LOOP_ONE_ACTIVATE = '🔂 Looping the current song'
|
||||||
COMMAND_NOT_FOUND = f'❌ Command not found, type {BOT_PREFIX}help to see all commands'
|
self.LOOP_DISABLE = '➡️ Loop disabled'
|
||||||
UNKNOWN_ERROR = f'❌ Unknown Error, if needed, use {BOT_PREFIX}reset to reset the player of your server'
|
self.LOOP_ALREADY_DISABLE = '❌ Loop is already disabled'
|
||||||
ERROR_MISSING_ARGUMENTS = f'❌ Missing arguments in this command. Type {BOT_PREFIX}help "command" to see more info about this command'
|
self.LOOP_ON = f'❌ This command cannot be invoked with any loop activated. Use {self.BOT_PREFIX}loop off to disable loop'
|
||||||
NOT_PREVIOUS = '❌ There is none previous song to play'
|
|
||||||
PLAYER_NOT_PLAYING = f'❌ No song playing. Use {BOT_PREFIX}play to start the player'
|
|
||||||
IMPOSSIBLE_MOVE = 'That is impossible :('
|
|
||||||
ERROR_TITLE = 'Error :-('
|
|
||||||
NO_CHANNEL = 'To play some music, connect to any voice channel first.'
|
|
||||||
NO_GUILD = f'This server does not has a Player, try {BOT_PREFIX}reset'
|
|
||||||
INVALID_INPUT = f'This type of input was too strange, try something better or type {BOT_PREFIX}help play'
|
|
||||||
DOWNLOADING_ERROR = '❌ An error occurred while downloading'
|
|
||||||
EXTRACTING_ERROR = '❌ An error ocurred while searching for the songs'
|
|
||||||
|
|
||||||
MY_ERROR_BAD_COMMAND = 'This string serves to verify if some error was raised by myself on purpose'
|
self.SONGS_SHUFFLED = '🔀 Songs shuffled successfully'
|
||||||
BAD_COMMAND_TITLE = 'Misuse of command'
|
self.ERROR_SHUFFLING = '❌ Error while shuffling the songs'
|
||||||
BAD_COMMAND = f'❌ Bad usage of this command, type {BOT_PREFIX}help "command" to understand the command better'
|
self.ERROR_MOVING = '❌ Error while moving the songs'
|
||||||
|
self.LENGTH_ERROR = '❌ Numbers must be between 1 and queue length, use -1 for the last song'
|
||||||
|
self.ERROR_NUMBER = '❌ This command require a number'
|
||||||
|
self.ERROR_PLAYING = '❌ Error while playing songs'
|
||||||
|
self.COMMAND_NOT_FOUND = f'❌ Command not found, type {self.BOT_PREFIX}help to see all commands'
|
||||||
|
self.UNKNOWN_ERROR = f'❌ Unknown Error, if needed, use {self.BOT_PREFIX}reset to reset the player of your server'
|
||||||
|
self.ERROR_MISSING_ARGUMENTS = f'❌ Missing arguments in this command. Type {self.BOT_PREFIX}help "command" to see more info about this command'
|
||||||
|
self.NOT_PREVIOUS = '❌ There is none previous song to play'
|
||||||
|
self.PLAYER_NOT_PLAYING = f'❌ No song playing. Use {self.BOT_PREFIX}play to start the player'
|
||||||
|
self.IMPOSSIBLE_MOVE = 'That is impossible :('
|
||||||
|
self.ERROR_TITLE = 'Error :-('
|
||||||
|
self.NO_CHANNEL = 'To play some music, connect to any voice channel first.'
|
||||||
|
self.NO_GUILD = f'This server does not has a Player, try {self.BOT_PREFIX}reset'
|
||||||
|
self.INVALID_INPUT = f'This type of input was too strange, try something better or type {self.BOT_PREFIX}help play'
|
||||||
|
self.DOWNLOADING_ERROR = '❌ An error occurred while downloading'
|
||||||
|
self.EXTRACTING_ERROR = '❌ An error ocurred while searching for the songs'
|
||||||
|
|
||||||
COLOURS = {
|
self.MY_ERROR_BAD_COMMAND = 'This string serves to verify if some error was raised by myself on purpose'
|
||||||
'red': 0xDC143C,
|
self.BAD_COMMAND_TITLE = 'Misuse of command'
|
||||||
'green': 0x1F8B4C,
|
self.BAD_COMMAND = f'❌ Bad usage of this command, type {self.BOT_PREFIX}help "command" to understand the command better'
|
||||||
'grey': 0x708090,
|
|
||||||
'blue': 0x206694,
|
self.COLOURS = {
|
||||||
'black': 0x23272A
|
'red': 0xDC143C,
|
||||||
}
|
'green': 0x1F8B4C,
|
||||||
|
'grey': 0x708090,
|
||||||
|
'blue': 0x206694,
|
||||||
|
'black': 0x23272A
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
from config.config import *
|
|
||||||
|
|
||||||
HELP_SKIP = 'Skip the current playing song.'
|
|
||||||
HELP_SKIP_LONG = 'Skip the playing of the current song, does not work if loop one is activated. \n\nArguments: None.'
|
|
||||||
HELP_RESUME = 'Resumes the song player.'
|
|
||||||
HELP_RESUME_LONG = 'If the player if paused, return the playing. \n\nArguments: None.'
|
|
||||||
HELP_CLEAR = 'Clear the queue and songs history.'
|
|
||||||
HELP_CLEAR_LONG = 'Clear the songs queue and songs history. \n\nArguments: None.'
|
|
||||||
HELP_STOP = 'Stop the song player.'
|
|
||||||
HELP_STOP_LONG = 'Stop the song player, clear queue and history and remove Vulkan from voice channel.\n\nArguments: None.'
|
|
||||||
HELP_LOOP = 'Control the loop of songs.'
|
|
||||||
HELP_LOOP_LONG = """Control the loop of songs.\n\n Require: A song being played.\nArguments:
|
|
||||||
One - Start looping the current song.
|
|
||||||
All - Start looping all songs in queue.
|
|
||||||
Off - Disable loop."""
|
|
||||||
HELP_NP = 'Show the info of the current song.'
|
|
||||||
HELP_NP_LONG = 'Show the information of the song being played.\n\nRequire: A song being played.\nArguments: None.'
|
|
||||||
HELP_QUEUE = f'Show the first {MAX_PRELOAD_SONGS} songs in queue.'
|
|
||||||
HELP_QUEUE_LONG = f'Show the first {MAX_PRELOAD_SONGS} song in the queue.\n\nArguments: None.'
|
|
||||||
HELP_PAUSE = 'Pauses the song player.'
|
|
||||||
HELP_PAUSE_LONG = 'If playing, pauses the song player.\n\nArguments: None'
|
|
||||||
HELP_PREV = 'Play the previous song.'
|
|
||||||
HELP_PREV_LONG = 'Play the previous song. If playing, the current song will return to queue.\n\nRequire: Loop to be disable.\nArguments: None.'
|
|
||||||
HELP_SHUFFLE = 'Shuffle the songs playing.'
|
|
||||||
HELP_SHUFFLE_LONG = 'Randomly shuffle the songs in the queue.\n\nArguments: None.'
|
|
||||||
HELP_PLAY = 'Plays a song.'
|
|
||||||
HELP_PLAY_LONG = 'Play a song in discord. \n\nRequire: You to be connected to a voice channel.\nArguments: Youtube or Spotify song/playlist link or the title of the song to be searched in Youtube.'
|
|
||||||
HELP_HISTORY = f'Show the history of played songs.'
|
|
||||||
HELP_HISTORY_LONG = f'Show the last {MAX_SONGS_HISTORY} played songs'
|
|
||||||
HELP_MOVE = 'Moves a song from position x to y in queue.'
|
|
||||||
HELP_MOVE_LONG = 'Moves a song from position x to position y in queue.\n\nRequire: Positions to be both valid numbers.\nArguments: 1º Number => Initial position, 2º Number => Destination position. Both numbers could be -1 to refer to the last song in queue.\nDefault: By default, if the second number is not passed, it will be 1, moving the selected song to 1º position.'
|
|
||||||
HELP_REMOVE = 'Remove a song in position x.'
|
|
||||||
HELP_REMOVE_LONG = 'Remove a song from queue in the position passed.\n\nRequire: Position to be a valid number.\nArguments: 1º Number => Position in queue of the song.'
|
|
||||||
HELP_RESET = 'Reset the Player of the server.'
|
|
||||||
HELP_RESET_LONG = 'Reset the Player of the server. Recommended if you find any type of error.\n\nArguments: None'
|
|
||||||
HELP_HELP = f'Use {BOT_PREFIX}help "command" for more info.'
|
|
||||||
HELP_HELP_LONG = f'Use {BOT_PREFIX}help command for more info about the command selected.'
|
|
||||||
HELP_INVITE = 'Send the invite URL to call Vulkan to your server.'
|
|
||||||
HELP_INVITE_LONG = 'Send an message in text channel with a URL to be used to invite Vulkan to your own server.\n\nArguments: None.'
|
|
||||||
HELP_RANDOM = 'Return a random number between 1 and x.'
|
|
||||||
HELP_RANDOM_LONG = 'Send a randomly selected number between 1 and the number you pass.\n\nRequired: Number to be a valid number.\nArguments: 1º Any number to be used as range.'
|
|
||||||
HELP_CHOOSE = 'Choose randomly one item passed.'
|
|
||||||
HELP_CHOOSE_LONG = 'Choose randomly one item passed in this command.\n\nRequire: Itens to be separated by comma.\nArguments: As much as you want.'
|
|
||||||
HELP_CARA = 'Return cara or coroa.'
|
|
||||||
HELP_CARA_LONG = 'Return cara or coroa.'
|
|
||||||
3
main.py
3
main.py
@@ -1,11 +1,12 @@
|
|||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
|
config = Config()
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True,
|
bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True,
|
||||||
case_insensitive=True, intents=intents)
|
case_insensitive=True, intents=intents)
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import discord
|
|||||||
from discord import Client
|
from discord import Client
|
||||||
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument, UserInputError
|
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument, UserInputError
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from config import help
|
from config.Helper import Helper
|
||||||
|
|
||||||
|
helper = Helper()
|
||||||
|
|
||||||
|
|
||||||
class Control(commands.Cog):
|
class Control(commands.Cog):
|
||||||
@@ -11,6 +13,7 @@ class Control(commands.Cog):
|
|||||||
|
|
||||||
def __init__(self, bot: Client):
|
def __init__(self, bot: Client):
|
||||||
self.__bot = bot
|
self.__bot = bot
|
||||||
|
self.__config = Config()
|
||||||
self.__comandos = {
|
self.__comandos = {
|
||||||
'MUSIC': ['resume', 'pause', 'loop', 'stop',
|
'MUSIC': ['resume', 'pause', 'loop', 'stop',
|
||||||
'skip', 'play', 'queue', 'clear',
|
'skip', 'play', 'queue', 'clear',
|
||||||
@@ -22,36 +25,36 @@ class Control(commands.Cog):
|
|||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(config.STARTUP_MESSAGE)
|
print(self.__config.STARTUP_MESSAGE)
|
||||||
await self.__bot.change_presence(status=discord.Status.online, activity=discord.Game(name=f"Vulkan | {config.BOT_PREFIX}help"))
|
await self.__bot.change_presence(status=discord.Status.online, activity=discord.Game(name=f"Vulkan | {self.__config.BOT_PREFIX}help"))
|
||||||
print(config.STARTUP_COMPLETE_MESSAGE)
|
print(self.__config.STARTUP_COMPLETE_MESSAGE)
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
if isinstance(error, MissingRequiredArgument):
|
if isinstance(error, MissingRequiredArgument):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.ERROR_MISSING_ARGUMENTS,
|
description=self.__config.ERROR_MISSING_ARGUMENTS,
|
||||||
colour=config.COLOURS['black']
|
colour=self.__config.COLOURS['black']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
elif isinstance(error, CommandNotFound):
|
elif isinstance(error, CommandNotFound):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.COMMAND_NOT_FOUND,
|
description=self.__config.COMMAND_NOT_FOUND,
|
||||||
colour=config.COLOURS['black']
|
colour=self.__config.COLOURS['black']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
elif isinstance(error, UserInputError):
|
elif isinstance(error, UserInputError):
|
||||||
my_error = False
|
my_error = False
|
||||||
if len(error.args) > 0:
|
if len(error.args) > 0:
|
||||||
for arg in error.args:
|
for arg in error.args:
|
||||||
if arg == config.MY_ERROR_BAD_COMMAND:
|
if arg == self.__config.MY_ERROR_BAD_COMMAND:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=config.BAD_COMMAND_TITLE,
|
title=self.__config.BAD_COMMAND_TITLE,
|
||||||
description=config.BAD_COMMAND,
|
description=self.__config.BAD_COMMAND,
|
||||||
colour=config.COLOURS['black']
|
colour=self.__config.COLOURS['black']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
my_error = True
|
my_error = True
|
||||||
@@ -61,13 +64,13 @@ class Control(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
print(f'DEVELOPER NOTE -> Comand Error: {error}')
|
print(f'DEVELOPER NOTE -> Comand Error: {error}')
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.UNKNOWN_ERROR,
|
description=self.__config.UNKNOWN_ERROR,
|
||||||
colour=config.COLOURS['red']
|
colour=self.__config.COLOURS['red']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name="help", help=help.HELP_HELP, description=help.HELP_HELP_LONG, aliases=['h', 'ajuda'])
|
@commands.command(name="help", help=helper.HELP_HELP, description=helper.HELP_HELP_LONG, aliases=['h', 'ajuda'])
|
||||||
async def help_msg(self, ctx, command_help=''):
|
async def help_msg(self, ctx, command_help=''):
|
||||||
if command_help != '':
|
if command_help != '':
|
||||||
for command in self.__bot.commands:
|
for command in self.__bot.commands:
|
||||||
@@ -77,7 +80,7 @@ class Control(commands.Cog):
|
|||||||
embedhelp = discord.Embed(
|
embedhelp = discord.Embed(
|
||||||
title=f'**Description of {command_help}** command',
|
title=f'**Description of {command_help}** command',
|
||||||
description=txt,
|
description=txt,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.send(embed=embedhelp)
|
await ctx.send(embed=embedhelp)
|
||||||
@@ -86,7 +89,7 @@ class Control(commands.Cog):
|
|||||||
embedhelp = discord.Embed(
|
embedhelp = discord.Embed(
|
||||||
title='Command Help',
|
title='Command Help',
|
||||||
description=f'Command {command_help} Not Found',
|
description=f'Command {command_help} Not Found',
|
||||||
colour=config.COLOURS['red']
|
colour=self.__config.COLOURS['red']
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.send(embed=embedhelp)
|
await ctx.send(embed=embedhelp)
|
||||||
@@ -108,26 +111,26 @@ class Control(commands.Cog):
|
|||||||
help_help += f'**{command}** - {command.help}\n'
|
help_help += f'**{command}** - {command.help}\n'
|
||||||
|
|
||||||
helptxt = f'\n{help_music}\n{help_help}\n{help_random}'
|
helptxt = f'\n{help_music}\n{help_help}\n{help_random}'
|
||||||
helptxt += f'\n\nType {config.BOT_PREFIX}help "command" for more information about the command chosen'
|
helptxt += f'\n\nType {self.__config.BOT_PREFIX}help "command" for more information about the command chosen'
|
||||||
embedhelp = discord.Embed(
|
embedhelp = discord.Embed(
|
||||||
title=f'**Available Commands of {self.__bot.user.name}**',
|
title=f'**Available Commands of {self.__bot.user.name}**',
|
||||||
description=helptxt,
|
description=helptxt,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
|
|
||||||
embedhelp.set_thumbnail(url=self.__bot.user.avatar_url)
|
embedhelp.set_thumbnail(url=self.__bot.user.avatar_url)
|
||||||
await ctx.send(embed=embedhelp)
|
await ctx.send(embed=embedhelp)
|
||||||
|
|
||||||
@commands.command(name='invite', help=help.HELP_INVITE, description=help.HELP_INVITE_LONG)
|
@commands.command(name='invite', help=helper.HELP_INVITE, description=helper.HELP_INVITE_LONG)
|
||||||
async def invite_bot(self, ctx):
|
async def invite_bot(self, ctx):
|
||||||
invite_url = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot>'.format(
|
invite_url = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot>'.format(
|
||||||
self.__bot.user.id)
|
self.__bot.user.id)
|
||||||
txt = config.INVITE_MESSAGE.format(invite_url)
|
txt = self.__config.INVITE_MESSAGE.format(invite_url)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Invite Vulkan",
|
title="Invite Vulkan",
|
||||||
description=txt,
|
description=txt,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|||||||
@@ -2,17 +2,20 @@ from typing import Dict
|
|||||||
from discord import Guild, Client, Embed
|
from discord import Guild, Client, Embed
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from config import help
|
from config.Helper import Helper
|
||||||
from vulkan.music.Player import Player
|
from vulkan.music.Player import Player
|
||||||
from vulkan.music.utils import is_connected
|
from vulkan.music.utils import is_connected
|
||||||
from vulkan.controllers.SkipController import SkipHandler
|
from vulkan.controllers.SkipController import SkipHandler
|
||||||
|
|
||||||
|
helper = Helper()
|
||||||
|
|
||||||
|
|
||||||
class Music(commands.Cog):
|
class Music(commands.Cog):
|
||||||
def __init__(self, bot) -> None:
|
def __init__(self, bot) -> None:
|
||||||
self.__guilds: Dict[Guild, Player] = {}
|
self.__guilds: Dict[Guild, Player] = {}
|
||||||
self.__bot: Client = bot
|
self.__bot: Client = bot
|
||||||
|
self.__config = Config()
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_ready(self) -> None:
|
async def on_ready(self) -> None:
|
||||||
@@ -37,25 +40,25 @@ class Music(commands.Cog):
|
|||||||
self.__guilds.pop(guild, None)
|
self.__guilds.pop(guild, None)
|
||||||
print(f'Player for guild {guild.name} destroyed')
|
print(f'Player for guild {guild.name} destroyed')
|
||||||
|
|
||||||
@commands.command(name="play", help=help.HELP_PLAY, description=help.HELP_PLAY_LONG, aliases=['p', 'tocar'])
|
@commands.command(name="play", help=helper.HELP_PLAY, description=helper.HELP_PLAY_LONG, aliases=['p', 'tocar'])
|
||||||
async def play(self, ctx: Context, *args) -> None:
|
async def play(self, ctx: Context, *args) -> None:
|
||||||
track = " ".join(args)
|
track = " ".join(args)
|
||||||
requester = ctx.author.name
|
requester = ctx.author.name
|
||||||
|
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
await self.__send_embed(ctx, config.ERROR_TITLE, config.NO_GUILD, 'red')
|
await self.__send_embed(ctx, self.__config.ERROR_TITLE, self.__config.NO_GUILD, 'red')
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_connected(ctx) is None:
|
if is_connected(ctx) is None:
|
||||||
success = await player.connect(ctx)
|
success = await player.connect(ctx)
|
||||||
if success == False:
|
if success == False:
|
||||||
await self.__send_embed(ctx, config.IMPOSSIBLE_MOVE, config.NO_CHANNEL, 'red')
|
await self.__send_embed(ctx, self.__config.IMPOSSIBLE_MOVE, self.__config.NO_CHANNEL, 'red')
|
||||||
return
|
return
|
||||||
|
|
||||||
await player.play(ctx, track, requester)
|
await player.play(ctx, track, requester)
|
||||||
|
|
||||||
@commands.command(name="queue", help=help.HELP_QUEUE, description=help.HELP_QUEUE_LONG, aliases=['q', 'fila'])
|
@commands.command(name="queue", help=helper.HELP_QUEUE, description=helper.HELP_QUEUE_LONG, aliases=['q', 'fila'])
|
||||||
async def queue(self, ctx: Context) -> None:
|
async def queue(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -64,24 +67,20 @@ class Music(commands.Cog):
|
|||||||
embed = await player.queue()
|
embed = await player.queue()
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name="skip", help=help.HELP_SKIP, description=help.HELP_SKIP_LONG, aliases=['s', 'pular'])
|
@commands.command(name="skip", help=helper.HELP_SKIP, description=helper.HELP_SKIP_LONG, aliases=['s', 'pular'])
|
||||||
async def skip(self, ctx: Context) -> None:
|
async def skip(self, ctx: Context) -> None:
|
||||||
print(ctx.bot == self.__bot)
|
|
||||||
|
|
||||||
handler = SkipHandler(ctx, self.__bot)
|
handler = SkipHandler(ctx, self.__bot)
|
||||||
await handler.run()
|
await handler.run()
|
||||||
|
|
||||||
@commands.command(name='stop', help=help.HELP_STOP, description=help.HELP_STOP_LONG, aliases=['parar'])
|
@commands.command(name='stop', help=helper.HELP_STOP, description=helper.HELP_STOP_LONG, aliases=['parar'])
|
||||||
async def stop(self, ctx: Context) -> None:
|
async def stop(self, ctx: Context) -> None:
|
||||||
print(ctx.bot == self.__bot)
|
|
||||||
|
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
await player.stop()
|
await player.stop()
|
||||||
|
|
||||||
@commands.command(name='pause', help=help.HELP_PAUSE, description=help.HELP_PAUSE_LONG, aliases=['pausar'])
|
@commands.command(name='pause', help=helper.HELP_PAUSE, description=helper.HELP_PAUSE_LONG, aliases=['pausar'])
|
||||||
async def pause(self, ctx: Context) -> None:
|
async def pause(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -89,9 +88,9 @@ class Music(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
success = await player.pause()
|
success = await player.pause()
|
||||||
if success:
|
if success:
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, config.SONG_PAUSED, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, self.__config.SONG_PAUSED, 'blue')
|
||||||
|
|
||||||
@commands.command(name='resume', help=help.HELP_RESUME, description=help.HELP_RESUME_LONG, aliases=['soltar'])
|
@commands.command(name='resume', help=helper.HELP_RESUME, description=helper.HELP_RESUME_LONG, aliases=['soltar'])
|
||||||
async def resume(self, ctx: Context) -> None:
|
async def resume(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -99,9 +98,9 @@ class Music(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
success = await player.resume()
|
success = await player.resume()
|
||||||
if success:
|
if success:
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, config.SONG_RESUMED, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, self.__config.SONG_RESUMED, 'blue')
|
||||||
|
|
||||||
@commands.command(name='prev', help=help.HELP_PREV, description=help.HELP_PREV_LONG, aliases=['anterior'])
|
@commands.command(name='prev', help=helper.HELP_PREV, description=helper.HELP_PREV_LONG, aliases=['anterior'])
|
||||||
async def prev(self, ctx: Context) -> None:
|
async def prev(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -110,12 +109,12 @@ class Music(commands.Cog):
|
|||||||
if is_connected(ctx) is None:
|
if is_connected(ctx) is None:
|
||||||
success = await player.connect(ctx)
|
success = await player.connect(ctx)
|
||||||
if success == False:
|
if success == False:
|
||||||
await self.__send_embed(ctx, config.IMPOSSIBLE_MOVE, config.NO_CHANNEL, 'red')
|
await self.__send_embed(ctx, self.__config.IMPOSSIBLE_MOVE, self.__config.NO_CHANNEL, 'red')
|
||||||
return
|
return
|
||||||
|
|
||||||
await player.play_prev(ctx)
|
await player.play_prev(ctx)
|
||||||
|
|
||||||
@commands.command(name='history', help=help.HELP_HISTORY, description=help.HELP_HISTORY_LONG, aliases=['historico'])
|
@commands.command(name='history', help=helper.HELP_HISTORY, description=helper.HELP_HISTORY_LONG, aliases=['historico'])
|
||||||
async def history(self, ctx: Context) -> None:
|
async def history(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -124,16 +123,16 @@ class Music(commands.Cog):
|
|||||||
embed = player.history()
|
embed = player.history()
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name='loop', help=help.HELP_LOOP, description=help.HELP_LOOP_LONG, aliases=['l', 'repeat'])
|
@commands.command(name='loop', help=helper.HELP_LOOP, description=helper.HELP_LOOP_LONG, aliases=['l', 'repeat'])
|
||||||
async def loop(self, ctx: Context, args: str) -> None:
|
async def loop(self, ctx: Context, args: str) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
description = await player.loop(args)
|
description = await player.loop(args)
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, description, 'blue')
|
||||||
|
|
||||||
@commands.command(name='clear', help=help.HELP_CLEAR, description=help.HELP_CLEAR_LONG, aliases=['c', 'limpar'])
|
@commands.command(name='clear', help=helper.HELP_CLEAR, description=helper.HELP_CLEAR_LONG, aliases=['c', 'limpar'])
|
||||||
async def clear(self, ctx: Context) -> None:
|
async def clear(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -141,7 +140,7 @@ class Music(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await player.clear()
|
await player.clear()
|
||||||
|
|
||||||
@commands.command(name='np', help=help.HELP_NP, description=help.HELP_NP_LONG, aliases=['playing', 'now'])
|
@commands.command(name='np', help=helper.HELP_NP, description=helper.HELP_NP_LONG, aliases=['playing', 'now'])
|
||||||
async def now_playing(self, ctx: Context) -> None:
|
async def now_playing(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
@@ -151,34 +150,34 @@ class Music(commands.Cog):
|
|||||||
await self.__clean_messages(ctx)
|
await self.__clean_messages(ctx)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name='shuffle', help=help.HELP_SHUFFLE, description=help.HELP_SHUFFLE_LONG, aliases=['aleatorio'])
|
@commands.command(name='shuffle', help=helper.HELP_SHUFFLE, description=helper.HELP_SHUFFLE_LONG, aliases=['aleatorio'])
|
||||||
async def shuffle(self, ctx: Context) -> None:
|
async def shuffle(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
description = await player.shuffle()
|
description = await player.shuffle()
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, description, 'blue')
|
||||||
|
|
||||||
@commands.command(name='move', help=help.HELP_MOVE, description=help.HELP_MOVE_LONG, aliases=['m', 'mover'])
|
@commands.command(name='move', help=helper.HELP_MOVE, description=helper.HELP_MOVE_LONG, aliases=['m', 'mover'])
|
||||||
async def move(self, ctx: Context, pos1, pos2='1') -> None:
|
async def move(self, ctx: Context, pos1, pos2='1') -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
description = await player.move(pos1, pos2)
|
description = await player.move(pos1, pos2)
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, description, 'blue')
|
||||||
|
|
||||||
@commands.command(name='remove', help=help.HELP_REMOVE, description=help.HELP_REMOVE_LONG, aliases=['remover'])
|
@commands.command(name='remove', help=helper.HELP_REMOVE, description=helper.HELP_REMOVE_LONG, aliases=['remover'])
|
||||||
async def remove(self, ctx: Context, position) -> None:
|
async def remove(self, ctx: Context, position) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
if player is None:
|
if player is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
description = await player.remove(position)
|
description = await player.remove(position)
|
||||||
await self.__send_embed(ctx, config.SONG_PLAYER, description, 'blue')
|
await self.__send_embed(ctx, self.__config.SONG_PLAYER, description, 'blue')
|
||||||
|
|
||||||
@commands.command(name='reset', help=help.HELP_RESET, description=help.HELP_RESET_LONG, aliases=['resetar'])
|
@commands.command(name='reset', help=helper.HELP_RESET, description=helper.HELP_RESET_LONG, aliases=['resetar'])
|
||||||
async def reset(self, ctx: Context) -> None:
|
async def reset(self, ctx: Context) -> None:
|
||||||
player = self.__get_player(ctx)
|
player = self.__get_player(ctx)
|
||||||
try:
|
try:
|
||||||
@@ -196,9 +195,9 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
async def __send_embed(self, ctx: Context, title='', description='', colour='grey') -> None:
|
async def __send_embed(self, ctx: Context, title='', description='', colour='grey') -> None:
|
||||||
try:
|
try:
|
||||||
colour = config.COLOURS[colour]
|
colour = self.__config.COLOURS[colour]
|
||||||
except:
|
except:
|
||||||
colour = config.COLOURS['grey']
|
colour = self.__config.COLOURS['grey']
|
||||||
|
|
||||||
embedvc = Embed(
|
embedvc = Embed(
|
||||||
title=title,
|
title=title,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
from random import randint, random
|
from random import randint, random
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from config import help
|
from config.Helper import Helper
|
||||||
|
|
||||||
|
helper = Helper()
|
||||||
|
|
||||||
|
|
||||||
class Random(commands.Cog):
|
class Random(commands.Cog):
|
||||||
@@ -10,16 +12,17 @@ class Random(commands.Cog):
|
|||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.__bot = bot
|
self.__bot = bot
|
||||||
|
self.__config = Config()
|
||||||
|
|
||||||
@commands.command(name='random', help=help.HELP_RANDOM, description=help.HELP_RANDOM_LONG)
|
@commands.command(name='random', help=helper.HELP_RANDOM, description=helper.HELP_RANDOM_LONG)
|
||||||
async def random(self, ctx, arg: str) -> None:
|
async def random(self, ctx, arg: str) -> None:
|
||||||
try:
|
try:
|
||||||
arg = int(arg)
|
arg = int(arg)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description=config.ERROR_NUMBER,
|
description=self.__config.ERROR_NUMBER,
|
||||||
colour=config.COLOURS['red']
|
colour=self.__config.COLOURS['red']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return
|
return
|
||||||
@@ -35,11 +38,11 @@ class Random(commands.Cog):
|
|||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=f'Random number between [{a, b}]',
|
title=f'Random number between [{a, b}]',
|
||||||
description=x,
|
description=x,
|
||||||
colour=config.COLOURS['green']
|
colour=self.__config.COLOURS['green']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name='cara', help=help.HELP_CARA, description=help.HELP_CARA_LONG)
|
@commands.command(name='cara', help=helper.HELP_CARA, description=helper.HELP_CARA_LONG)
|
||||||
async def cara(self, ctx) -> None:
|
async def cara(self, ctx) -> None:
|
||||||
x = random()
|
x = random()
|
||||||
if x < 0.5:
|
if x < 0.5:
|
||||||
@@ -50,11 +53,11 @@ class Random(commands.Cog):
|
|||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title='Cara Cora',
|
title='Cara Cora',
|
||||||
description=f'Result: {result}',
|
description=f'Result: {result}',
|
||||||
colour=config.COLOURS['green']
|
colour=self.__config.COLOURS['green']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command(name='choose', help=help.HELP_CHOOSE, description=help.HELP_CHOOSE_LONG)
|
@commands.command(name='choose', help=helper.HELP_CHOOSE, description=helper.HELP_CHOOSE_LONG)
|
||||||
async def choose(self, ctx, *args: str) -> None:
|
async def choose(self, ctx, *args: str) -> None:
|
||||||
try:
|
try:
|
||||||
user_input = " ".join(args)
|
user_input = " ".join(args)
|
||||||
@@ -65,14 +68,14 @@ class Random(commands.Cog):
|
|||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title='Choose something',
|
title='Choose something',
|
||||||
description=itens[index],
|
description=itens[index],
|
||||||
colour=config.COLOURS['green']
|
colour=self.__config.COLOURS['green']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
except:
|
except:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title='Choose something.',
|
title='Choose something.',
|
||||||
description=f'Error: Use {config.BOT_PREFIX}help choose to understand this command.',
|
description=f'Error: Use {self.__config.BOT_PREFIX}help choose to understand this command.',
|
||||||
colour=config.COLOURS['red']
|
colour=self.__config.COLOURS['red']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import List
|
from typing import List
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from yt_dlp import YoutubeDL
|
from yt_dlp import YoutubeDL
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from vulkan.music.Song import Song
|
from vulkan.music.Song import Song
|
||||||
@@ -9,6 +9,7 @@ from vulkan.music.utils import is_url, run_async
|
|||||||
|
|
||||||
class Downloader():
|
class Downloader():
|
||||||
"""Download musics direct URL and title or Source from Youtube using a music name or Youtube URL"""
|
"""Download musics direct URL and title or Source from Youtube using a music name or Youtube URL"""
|
||||||
|
config = Config()
|
||||||
__YDL_OPTIONS = {'format': 'bestaudio/best',
|
__YDL_OPTIONS = {'format': 'bestaudio/best',
|
||||||
'default_search': 'auto',
|
'default_search': 'auto',
|
||||||
'playliststart': 0,
|
'playliststart': 0,
|
||||||
@@ -30,6 +31,7 @@ class Downloader():
|
|||||||
__BASE_URL = 'https://www.youtube.com/watch?v={}'
|
__BASE_URL = 'https://www.youtube.com/watch?v={}'
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
self.__config = Config()
|
||||||
self.__music_keys_only = ['resolution', 'fps', 'quality']
|
self.__music_keys_only = ['resolution', 'fps', 'quality']
|
||||||
self.__not_extracted_keys_only = ['ie_key']
|
self.__not_extracted_keys_only = ['ie_key']
|
||||||
self.__not_extracted_not_keys = ['entries']
|
self.__not_extracted_not_keys = ['entries']
|
||||||
@@ -127,7 +129,7 @@ class Downloader():
|
|||||||
|
|
||||||
# Creating a loop task to download each song
|
# Creating a loop task to download each song
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
executor = ThreadPoolExecutor(max_workers=config.MAX_PRELOAD_SONGS)
|
executor = ThreadPoolExecutor(max_workers=self.__config.MAX_PRELOAD_SONGS)
|
||||||
fs = {loop.run_in_executor(executor, __download_func, song)}
|
fs = {loop.run_in_executor(executor, __download_func, song)}
|
||||||
await asyncio.wait(fs=fs, return_when=asyncio.ALL_COMPLETED)
|
await asyncio.wait(fs=fs, return_when=asyncio.ALL_COMPLETED)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from discord import Client, Guild, FFmpegPCMAudio, Embed
|
from discord import Client, Guild, FFmpegPCMAudio, Embed
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@@ -21,6 +21,7 @@ class Player(commands.Cog):
|
|||||||
|
|
||||||
self.__timer = Timer(self.__timeout_handler)
|
self.__timer = Timer(self.__timeout_handler)
|
||||||
self.__playing = False
|
self.__playing = False
|
||||||
|
self.__config = Config.Config()
|
||||||
|
|
||||||
# Flag to control if the player should stop totally the playing
|
# Flag to control if the player should stop totally the playing
|
||||||
self.__force_stop = False
|
self.__force_stop = False
|
||||||
@@ -79,9 +80,9 @@ class Player(commands.Cog):
|
|||||||
links, provider = self.__searcher.search(track)
|
links, provider = self.__searcher.search(track)
|
||||||
if provider == Provider.Unknown or links == None:
|
if provider == Provider.Unknown or links == None:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.INVALID_INPUT,
|
description=self.__config.INVALID_INPUT,
|
||||||
colours=config.COLOURS['blue'])
|
colours=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -90,9 +91,9 @@ class Player(commands.Cog):
|
|||||||
|
|
||||||
if len(links) == 0:
|
if len(links) == 0:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description="This video is unavailable",
|
description="This video is unavailable",
|
||||||
colours=config.COLOURS['blue'])
|
colours=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -106,9 +107,9 @@ class Player(commands.Cog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'DEVELOPER NOTE -> Error while Downloading in Player: {e}')
|
print(f'DEVELOPER NOTE -> Error while Downloading in Player: {e}')
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.DOWNLOADING_ERROR,
|
description=self.__config.DOWNLOADING_ERROR,
|
||||||
colours=config.COLOURS['blue'])
|
colours=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -118,25 +119,25 @@ class Player(commands.Cog):
|
|||||||
|
|
||||||
if song.problematic:
|
if song.problematic:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.ERROR_TITLE,
|
title=self.__config.ERROR_TITLE,
|
||||||
description=config.DOWNLOADING_ERROR,
|
description=self.__config.DOWNLOADING_ERROR,
|
||||||
colours=config.COLOURS['blue'])
|
colours=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return None
|
return None
|
||||||
elif not self.__playing:
|
elif not self.__playing:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.SONG_ADDED.format(song.title),
|
description=self.__config.SONG_ADDED.format(song.title),
|
||||||
colour=config.COLOURS['blue'])
|
colour=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
else:
|
else:
|
||||||
embed = self.__format_embed(song.info, config.SONG_ADDED_TWO, pos)
|
embed = self.__format_embed(song.info, self.__config.SONG_ADDED_TWO, pos)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
else:
|
else:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.SONGS_ADDED.format(songs_quant),
|
description=self.__config.SONGS_ADDED.format(songs_quant),
|
||||||
colour=config.COLOURS['blue'])
|
colour=self.__config.COLOURS['blue'])
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
if not self.__playing:
|
if not self.__playing:
|
||||||
@@ -147,9 +148,9 @@ class Player(commands.Cog):
|
|||||||
"""Stop the currently playing cycle, load the previous song and play"""
|
"""Stop the currently playing cycle, load the previous song and play"""
|
||||||
if self.__playlist.looping_one or self.__playlist.looping_all: # Do not allow play if loop
|
if self.__playlist.looping_one or self.__playlist.looping_all: # Do not allow play if loop
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.LOOP_ON,
|
description=self.__config.LOOP_ON,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return None
|
return None
|
||||||
@@ -157,9 +158,9 @@ class Player(commands.Cog):
|
|||||||
song = self.__playlist.prev_song() # Prepare the prev song to play again
|
song = self.__playlist.prev_song() # Prepare the prev song to play again
|
||||||
if song == None:
|
if song == None:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.NOT_PREVIOUS,
|
description=self.__config.NOT_PREVIOUS,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
else:
|
else:
|
||||||
@@ -174,20 +175,20 @@ class Player(commands.Cog):
|
|||||||
async def queue(self) -> Embed:
|
async def queue(self) -> Embed:
|
||||||
if self.__playlist.looping_one:
|
if self.__playlist.looping_one:
|
||||||
info = self.__playlist.current.info
|
info = self.__playlist.current.info
|
||||||
title = config.ONE_SONG_LOOPING
|
title = self.__config.ONE_SONG_LOOPING
|
||||||
return self.__format_embed(info, title)
|
return self.__format_embed(info, title)
|
||||||
|
|
||||||
songs_preload = self.__playlist.songs_to_preload
|
songs_preload = self.__playlist.songs_to_preload
|
||||||
|
|
||||||
if len(songs_preload) == 0:
|
if len(songs_preload) == 0:
|
||||||
title = config.SONG_PLAYER
|
title = self.__config.SONG_PLAYER
|
||||||
text = config.EMPTY_QUEUE
|
text = self.__config.EMPTY_QUEUE
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if self.__playlist.looping_all:
|
if self.__playlist.looping_all:
|
||||||
title = config.ALL_SONGS_LOOPING
|
title = self.__config.ALL_SONGS_LOOPING
|
||||||
else:
|
else:
|
||||||
title = config.QUEUE_TITLE
|
title = self.__config.QUEUE_TITLE
|
||||||
|
|
||||||
await self.__down.preload(songs_preload)
|
await self.__down.preload(songs_preload)
|
||||||
|
|
||||||
@@ -198,13 +199,13 @@ class Player(commands.Cog):
|
|||||||
text = f'📜 Queue length: {total_songs} | ⌛ Duration: `{total_time}` downloaded \n\n'
|
text = f'📜 Queue length: {total_songs} | ⌛ Duration: `{total_time}` downloaded \n\n'
|
||||||
|
|
||||||
for pos, song in enumerate(songs_preload, start=1):
|
for pos, song in enumerate(songs_preload, start=1):
|
||||||
song_name = song.title if song.title else config.SONG_DOWNLOADING
|
song_name = song.title if song.title else self.__config.SONG_DOWNLOADING
|
||||||
text += f"**`{pos}` - ** {song_name} - `{format_time(song.duration)}`\n"
|
text += f"**`{pos}` - ** {song_name} - `{format_time(song.duration)}`\n"
|
||||||
|
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=title,
|
title=title,
|
||||||
description=text,
|
description=text,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
@@ -212,9 +213,9 @@ class Player(commands.Cog):
|
|||||||
async def skip(self, ctx: Context) -> bool:
|
async def skip(self, ctx: Context) -> bool:
|
||||||
if self.__playlist.looping_one:
|
if self.__playlist.looping_one:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.LOOP_ON,
|
description=self.__config.LOOP_ON,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return False
|
return False
|
||||||
@@ -229,17 +230,17 @@ class Player(commands.Cog):
|
|||||||
history = self.__playlist.songs_history
|
history = self.__playlist.songs_history
|
||||||
|
|
||||||
if len(history) == 0:
|
if len(history) == 0:
|
||||||
text = config.HISTORY_EMPTY
|
text = self.__config.HISTORY_EMPTY
|
||||||
|
|
||||||
else:
|
else:
|
||||||
text = f'\n📜 History Length: {len(history)} | Max: {config.MAX_SONGS_HISTORY}\n'
|
text = f'\n📜 History Length: {len(history)} | Max: {self.__config.MAX_SONGS_HISTORY}\n'
|
||||||
for pos, song in enumerate(history, start=1):
|
for pos, song in enumerate(history, start=1):
|
||||||
text += f"**`{pos}` - ** {song.title} - `{format_time(song.duration)}`\n"
|
text += f"**`{pos}` - ** {song.title} - `{format_time(song.duration)}`\n"
|
||||||
|
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.HISTORY_TITLE,
|
title=self.__config.HISTORY_TITLE,
|
||||||
description=text,
|
description=text,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@@ -285,7 +286,7 @@ class Player(commands.Cog):
|
|||||||
async def loop(self, args: str) -> str:
|
async def loop(self, args: str) -> str:
|
||||||
args = args.lower()
|
args = args.lower()
|
||||||
if self.__playlist.current == None:
|
if self.__playlist.current == None:
|
||||||
return config.PLAYER_NOT_PLAYING
|
return self.__config.PLAYER_NOT_PLAYING
|
||||||
|
|
||||||
if args == 'one':
|
if args == 'one':
|
||||||
description = self.__playlist.loop_one()
|
description = self.__playlist.loop_one()
|
||||||
@@ -294,7 +295,7 @@ class Player(commands.Cog):
|
|||||||
elif args == 'off':
|
elif args == 'off':
|
||||||
description = self.__playlist.loop_off()
|
description = self.__playlist.loop_off()
|
||||||
else:
|
else:
|
||||||
raise commands.UserInputError(config.MY_ERROR_BAD_COMMAND)
|
raise commands.UserInputError(self.__config.MY_ERROR_BAD_COMMAND)
|
||||||
|
|
||||||
return description
|
return description
|
||||||
|
|
||||||
@@ -304,16 +305,16 @@ class Player(commands.Cog):
|
|||||||
async def now_playing(self) -> Embed:
|
async def now_playing(self) -> Embed:
|
||||||
if not self.__playing:
|
if not self.__playing:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=config.SONG_PLAYER,
|
title=self.__config.SONG_PLAYER,
|
||||||
description=config.PLAYER_NOT_PLAYING,
|
description=self.__config.PLAYER_NOT_PLAYING,
|
||||||
colour=config.COLOURS['blue']
|
colour=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
if self.__playlist.looping_one:
|
if self.__playlist.looping_one:
|
||||||
title = config.ONE_SONG_LOOPING
|
title = self.__config.ONE_SONG_LOOPING
|
||||||
else:
|
else:
|
||||||
title = config.SONG_PLAYING
|
title = self.__config.SONG_PLAYING
|
||||||
|
|
||||||
current_song = self.__playlist.current
|
current_song = self.__playlist.current
|
||||||
embed = self.__format_embed(current_song.info, title)
|
embed = self.__format_embed(current_song.info, title)
|
||||||
@@ -326,20 +327,20 @@ class Player(commands.Cog):
|
|||||||
songs = self.__playlist.songs_to_preload
|
songs = self.__playlist.songs_to_preload
|
||||||
|
|
||||||
await self.__down.preload(songs)
|
await self.__down.preload(songs)
|
||||||
return config.SONGS_SHUFFLED
|
return self.__config.SONGS_SHUFFLED
|
||||||
except:
|
except:
|
||||||
return config.ERROR_SHUFFLING
|
return self.__config.ERROR_SHUFFLING
|
||||||
|
|
||||||
async def move(self, pos1, pos2='1') -> str:
|
async def move(self, pos1, pos2='1') -> str:
|
||||||
if not self.__playing:
|
if not self.__playing:
|
||||||
return config.PLAYER_NOT_PLAYING
|
return self.__config.PLAYER_NOT_PLAYING
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pos1 = int(pos1)
|
pos1 = int(pos1)
|
||||||
pos2 = int(pos2)
|
pos2 = int(pos2)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return config.ERROR_NUMBER
|
return self.__config.ERROR_NUMBER
|
||||||
|
|
||||||
result = self.__playlist.move_songs(pos1, pos2)
|
result = self.__playlist.move_songs(pos1, pos2)
|
||||||
|
|
||||||
@@ -350,13 +351,13 @@ class Player(commands.Cog):
|
|||||||
async def remove(self, position) -> str:
|
async def remove(self, position) -> str:
|
||||||
"""Remove a song from the queue in the position"""
|
"""Remove a song from the queue in the position"""
|
||||||
if not self.__playing:
|
if not self.__playing:
|
||||||
return config.PLAYER_NOT_PLAYING
|
return self.__config.PLAYER_NOT_PLAYING
|
||||||
|
|
||||||
try:
|
try:
|
||||||
position = int(position)
|
position = int(position)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return config.ERROR_NUMBER
|
return self.__config.ERROR_NUMBER
|
||||||
|
|
||||||
result = self.__playlist.remove_song(position)
|
result = self.__playlist.remove_song(position)
|
||||||
return result
|
return result
|
||||||
@@ -366,14 +367,14 @@ class Player(commands.Cog):
|
|||||||
embedvc = Embed(
|
embedvc = Embed(
|
||||||
title=title,
|
title=title,
|
||||||
description=f"[{info['title']}]({info['original_url']})",
|
description=f"[{info['title']}]({info['original_url']})",
|
||||||
color=config.COLOURS['blue']
|
color=self.__config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
|
|
||||||
embedvc.add_field(name=config.SONGINFO_UPLOADER,
|
embedvc.add_field(name=self.__config.SONGINFO_UPLOADER,
|
||||||
value=info['uploader'],
|
value=info['uploader'],
|
||||||
inline=False)
|
inline=False)
|
||||||
|
|
||||||
embedvc.add_field(name=config.SONGINFO_REQUESTER,
|
embedvc.add_field(name=self.__config.SONGINFO_REQUESTER,
|
||||||
value=info['requester'],
|
value=info['requester'],
|
||||||
inline=True)
|
inline=True)
|
||||||
|
|
||||||
@@ -382,15 +383,15 @@ class Player(commands.Cog):
|
|||||||
|
|
||||||
if 'duration' in info.keys():
|
if 'duration' in info.keys():
|
||||||
duration = str(timedelta(seconds=info['duration']))
|
duration = str(timedelta(seconds=info['duration']))
|
||||||
embedvc.add_field(name=config.SONGINFO_DURATION,
|
embedvc.add_field(name=self.__config.SONGINFO_DURATION,
|
||||||
value=f"{duration}",
|
value=f"{duration}",
|
||||||
inline=True)
|
inline=True)
|
||||||
else:
|
else:
|
||||||
embedvc.add_field(name=config.SONGINFO_DURATION,
|
embedvc.add_field(name=self.__config.SONGINFO_DURATION,
|
||||||
value=config.SONGINFO_UNKNOWN_DURATION,
|
value=self.__config.SONGINFO_UNKNOWN_DURATION,
|
||||||
inline=True)
|
inline=True)
|
||||||
|
|
||||||
embedvc.add_field(name=config.SONGINFO_POSITION,
|
embedvc.add_field(name=self.__config.SONGINFO_POSITION,
|
||||||
value=position,
|
value=position,
|
||||||
inline=True)
|
inline=True)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from typing import List
|
from typing import List
|
||||||
from config import config
|
from config.Config import Config
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from vulkan.music.Interfaces import IPlaylist
|
from vulkan.music.Interfaces import IPlaylist
|
||||||
@@ -11,6 +11,7 @@ class Playlist(IPlaylist):
|
|||||||
"""Class to manage and control the songs to play and played"""
|
"""Class to manage and control the songs to play and played"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
self.__config = Config()
|
||||||
self.__queue = deque() # Store the musics to play
|
self.__queue = deque() # Store the musics to play
|
||||||
self.__songs_history = deque() # Store the musics played
|
self.__songs_history = deque() # Store the musics played
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ class Playlist(IPlaylist):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def songs_to_preload(self) -> List[Song]:
|
def songs_to_preload(self) -> List[Song]:
|
||||||
return list(self.__queue)[:config.MAX_PRELOAD_SONGS]
|
return list(self.__queue)[:self.__config.MAX_PRELOAD_SONGS]
|
||||||
|
|
||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
return len(self.__queue)
|
return len(self.__queue)
|
||||||
@@ -55,7 +56,7 @@ class Playlist(IPlaylist):
|
|||||||
if played_song.problematic == False:
|
if played_song.problematic == False:
|
||||||
self.__songs_history.appendleft(played_song)
|
self.__songs_history.appendleft(played_song)
|
||||||
|
|
||||||
if len(self.__songs_history) > config.MAX_SONGS_HISTORY:
|
if len(self.__songs_history) > self.__config.MAX_SONGS_HISTORY:
|
||||||
self.__songs_history.pop() # Remove the older
|
self.__songs_history.pop() # Remove the older
|
||||||
|
|
||||||
elif self.__looping_one: # Insert the current song to play again
|
elif self.__looping_one: # Insert the current song to play again
|
||||||
@@ -107,13 +108,13 @@ class Playlist(IPlaylist):
|
|||||||
Return: Embed descrition to show to user
|
Return: Embed descrition to show to user
|
||||||
"""
|
"""
|
||||||
if self.__looping_all == True:
|
if self.__looping_all == True:
|
||||||
return config.LOOP_ALL_ON
|
return self.__config.LOOP_ALL_ON
|
||||||
|
|
||||||
elif self.__looping_one == True:
|
elif self.__looping_one == True:
|
||||||
return config.LOOP_ONE_ALREADY_ON
|
return self.__config.LOOP_ONE_ALREADY_ON
|
||||||
else:
|
else:
|
||||||
self.__looping_one = True
|
self.__looping_one = True
|
||||||
return config.LOOP_ONE_ACTIVATE
|
return self.__config.LOOP_ONE_ACTIVATE
|
||||||
|
|
||||||
def loop_all(self) -> str:
|
def loop_all(self) -> str:
|
||||||
"""Try to start the loop of all songs
|
"""Try to start the loop of all songs
|
||||||
@@ -121,23 +122,23 @@ class Playlist(IPlaylist):
|
|||||||
Return: Embed descrition to show to user
|
Return: Embed descrition to show to user
|
||||||
"""
|
"""
|
||||||
if self.__looping_one == True:
|
if self.__looping_one == True:
|
||||||
return config.LOOP_ONE_ON
|
return self.__config.LOOP_ONE_ON
|
||||||
|
|
||||||
elif self.__looping_all == True:
|
elif self.__looping_all == True:
|
||||||
return config.LOOP_ALL_ALREADY_ON
|
return self.__config.LOOP_ALL_ALREADY_ON
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.__looping_all = True
|
self.__looping_all = True
|
||||||
return config.LOOP_ALL_ACTIVATE
|
return self.__config.LOOP_ALL_ACTIVATE
|
||||||
|
|
||||||
def loop_off(self) -> str:
|
def loop_off(self) -> str:
|
||||||
"""Disable both types of loop"""
|
"""Disable both types of loop"""
|
||||||
if self.__looping_all == False and self.__looping_one == False:
|
if self.__looping_all == False and self.__looping_one == False:
|
||||||
return config.LOOP_ALREADY_DISABLE
|
return self.__config.LOOP_ALREADY_DISABLE
|
||||||
|
|
||||||
self.__looping_all = False
|
self.__looping_all = False
|
||||||
self.__looping_one = False
|
self.__looping_one = False
|
||||||
return config.LOOP_DISABLE
|
return self.__config.LOOP_DISABLE
|
||||||
|
|
||||||
def destroy_song(self, song_destroy: Song) -> None:
|
def destroy_song(self, song_destroy: Song) -> None:
|
||||||
"""Destroy a song object from the queue"""
|
"""Destroy a song object from the queue"""
|
||||||
@@ -158,7 +159,7 @@ class Playlist(IPlaylist):
|
|||||||
pos2 = len(self.__queue)
|
pos2 = len(self.__queue)
|
||||||
|
|
||||||
if pos2 not in range(1, len(self.__queue) + 1) or pos1 not in range(1, len(self.__queue) + 1):
|
if pos2 not in range(1, len(self.__queue) + 1) or pos1 not in range(1, len(self.__queue) + 1):
|
||||||
return config.LENGTH_ERROR
|
return self.__config.LENGTH_ERROR
|
||||||
|
|
||||||
try:
|
try:
|
||||||
song = self.__queue[pos1-1]
|
song = self.__queue[pos1-1]
|
||||||
@@ -167,23 +168,23 @@ class Playlist(IPlaylist):
|
|||||||
|
|
||||||
song1_name = song.title if song.title else song.identifier
|
song1_name = song.title if song.title else song.identifier
|
||||||
|
|
||||||
return config.SONG_MOVED_SUCCESSFULLY.format(song1_name, pos1, pos2)
|
return self.__config.SONG_MOVED_SUCCESSFULLY.format(song1_name, pos1, pos2)
|
||||||
except:
|
except:
|
||||||
return config.ERROR_MOVING
|
return self.__config.ERROR_MOVING
|
||||||
|
|
||||||
def remove_song(self, position) -> str:
|
def remove_song(self, position) -> str:
|
||||||
if position == -1:
|
if position == -1:
|
||||||
position = len(self.__queue)
|
position = len(self.__queue)
|
||||||
|
|
||||||
if position not in range(1, len(self.__queue) + 1):
|
if position not in range(1, len(self.__queue) + 1):
|
||||||
return config.LENGTH_ERROR
|
return self.__config.LENGTH_ERROR
|
||||||
else:
|
else:
|
||||||
song = self.__queue[position-1]
|
song = self.__queue[position-1]
|
||||||
self.__queue.remove(song)
|
self.__queue.remove(song)
|
||||||
|
|
||||||
song_name = song.title if song.title else song.identifier
|
song_name = song.title if song.title else song.identifier
|
||||||
|
|
||||||
return config.SONG_REMOVED_SUCCESSFULLY.format(song_name)
|
return self.__config.SONG_REMOVED_SUCCESSFULLY.format(song_name)
|
||||||
|
|
||||||
def history(self) -> list:
|
def history(self) -> list:
|
||||||
"""Return a list with the song title of all played songs"""
|
"""Return a list with the song title of all played songs"""
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyClientCredentials
|
from spotipy.oauth2 import SpotifyClientCredentials
|
||||||
from config import config
|
from config.Config import Config
|
||||||
|
|
||||||
|
|
||||||
class SpotifySearch():
|
class SpotifySearch():
|
||||||
@@ -9,6 +9,7 @@ class SpotifySearch():
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.__connected = False
|
self.__connected = False
|
||||||
self.__connect()
|
self.__connect()
|
||||||
|
self.__config = Config()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connected(self):
|
def connected(self):
|
||||||
@@ -18,7 +19,7 @@ class SpotifySearch():
|
|||||||
try:
|
try:
|
||||||
# Initialize the connection with Spotify API
|
# Initialize the connection with Spotify API
|
||||||
self.__api = spotipy.Spotify(auth_manager=SpotifyClientCredentials(
|
self.__api = spotipy.Spotify(auth_manager=SpotifyClientCredentials(
|
||||||
client_id=config.SPOTIFY_ID, client_secret=config.SPOTIFY_SECRET))
|
client_id=Config.SPOTIFY_ID, client_secret=self.__config.SPOTIFY_SECRET))
|
||||||
self.__connected = True
|
self.__connected = True
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import re
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
from config import config
|
from config.Config import Config
|
||||||
from functools import wraps, partial
|
from functools import wraps, partial
|
||||||
|
config = Config()
|
||||||
|
|
||||||
|
|
||||||
def is_connected(ctx):
|
def is_connected(ctx):
|
||||||
|
|||||||
Reference in New Issue
Block a user