mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Stability update
This commit is contained in:
parent
f27dc1de93
commit
140c1640d9
@ -58,6 +58,7 @@ class Messages(Singleton):
|
||||
self.PLAYER_NOT_PLAYING = f'❌ No song playing. Use {configs.BOT_PREFIX}play to start the player'
|
||||
self.IMPOSSIBLE_MOVE = 'That is impossible :('
|
||||
self.ERROR_TITLE = 'Error :-('
|
||||
self.COMMAND_NOT_FOUND_TITLE = 'This is strange :-('
|
||||
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 {configs.BOT_PREFIX}reset'
|
||||
self.INVALID_INPUT = f'This URL was too strange, try something better or type {configs.BOT_PREFIX}help play'
|
||||
|
||||
@ -66,9 +66,9 @@ class ControlCog(commands.Cog):
|
||||
return
|
||||
|
||||
embedhelp = Embed(
|
||||
title='Command Help',
|
||||
description=f'Command {command_help} Not Found',
|
||||
colour=self.__colors.RED
|
||||
title='Help',
|
||||
description=f'Command {command_help} do not exists, type {self.__config.BOT_PREFIX}help to see all commands',
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
|
||||
await ctx.send(embed=embedhelp)
|
||||
|
||||
@ -114,7 +114,7 @@ class MusicCog(commands.Cog):
|
||||
except Exception as e:
|
||||
print(f'[ERROR IN COG] -> {e}')
|
||||
|
||||
@commands.command(name='prev', help=helper.HELP_PREV, description=helper.HELP_PREV_LONG, aliases=['anterior', 'return', 'previous'])
|
||||
@commands.command(name='prev', help=helper.HELP_PREV, description=helper.HELP_PREV_LONG, aliases=['anterior', 'return', 'previous', 'back'])
|
||||
async def prev(self, ctx: Context) -> None:
|
||||
try:
|
||||
controller = PrevHandler(ctx, self.__bot)
|
||||
|
||||
@ -22,8 +22,8 @@ class ClearHandler(AbstractHandler):
|
||||
playlist.clear()
|
||||
processLock.release()
|
||||
processLock.release()
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
processManager.resetProcess(self.guild, self.ctx)
|
||||
embed = self.embeds.PLAYER_RESTARTED()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
return HandlerResponse(self.ctx)
|
||||
|
||||
@ -27,6 +27,7 @@ class LoopHandler(AbstractHandler):
|
||||
if args == '' or args is None:
|
||||
playlist.loop_all()
|
||||
embed = self.embeds.LOOP_ALL_ACTIVATED()
|
||||
processLock.release()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
args = args.lower()
|
||||
@ -50,7 +51,7 @@ class LoopHandler(AbstractHandler):
|
||||
embed = self.embeds.BAD_LOOP_USE()
|
||||
|
||||
processLock.release()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
return HandlerResponse(self.ctx, embed, error)
|
||||
else:
|
||||
processManager.resetProcess(self.guild, self.ctx)
|
||||
embed = self.embeds.PLAYER_RESTARTED()
|
||||
|
||||
@ -19,4 +19,7 @@ class PauseHandler(AbstractHandler):
|
||||
queue = processInfo.getQueue()
|
||||
queue.put(command)
|
||||
|
||||
return HandlerResponse(self.ctx)
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
embed = self.embeds.NOT_PLAYING()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
@ -113,13 +113,20 @@ class PlayHandler(AbstractHandler):
|
||||
tasks.append(task)
|
||||
|
||||
# In the original order, await for the task and then if successfully downloaded add in the playlist
|
||||
processManager = ProcessManager()
|
||||
for index, task in enumerate(tasks):
|
||||
await task
|
||||
song = songs[index]
|
||||
if not song.problematic: # If downloaded add to the playlist and send play command
|
||||
with processInfo.getLock():
|
||||
processInfo = processManager.getPlayerInfo(self.guild, self.ctx)
|
||||
processLock = processInfo.getLock()
|
||||
acquired = processLock.acquire(timeout=self.config.ACQUIRE_LOCK_TIMEOUT)
|
||||
if acquired:
|
||||
playlist.add_song(song)
|
||||
queue.put(playCommand)
|
||||
processLock.release()
|
||||
else:
|
||||
processManager.resetProcess(self.guild, self.ctx)
|
||||
|
||||
def __isUserConnected(self) -> bool:
|
||||
if self.ctx.author.voice:
|
||||
|
||||
@ -44,6 +44,7 @@ class PrevHandler(AbstractHandler):
|
||||
prevCommand = VCommands(VCommandsType.PREV, self.ctx.author.voice.channel.id)
|
||||
queue = processInfo.getQueue()
|
||||
queue.put(prevCommand)
|
||||
return HandlerResponse(self.ctx)
|
||||
|
||||
def __user_connected(self) -> bool:
|
||||
if self.ctx.author.voice:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
from discord.ext.commands import Context
|
||||
from discord import Client
|
||||
from Handlers.AbstractHandler import AbstractHandler
|
||||
@ -30,16 +29,16 @@ class QueueHandler(AbstractHandler):
|
||||
if playlist.isLoopingOne():
|
||||
song = playlist.getCurrentSong()
|
||||
embed = self.embeds.ONE_SONG_LOOPING(song.info)
|
||||
processLock.release() # Release the Lock
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
songs_preload = playlist.getSongsToPreload()
|
||||
allSongs = playlist.getSongs()
|
||||
if len(songs_preload) == 0:
|
||||
embed = self.embeds.EMPTY_QUEUE()
|
||||
processLock.release() # Release the Lock
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
asyncio.create_task(self.__down.preload(songs_preload))
|
||||
|
||||
if playlist.isLoopingAll():
|
||||
title = self.messages.ALL_SONGS_LOOPING
|
||||
else:
|
||||
|
||||
@ -19,4 +19,7 @@ class ResetHandler(AbstractHandler):
|
||||
queue = processInfo.getQueue()
|
||||
queue.put(command)
|
||||
|
||||
return HandlerResponse(self.ctx)
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
embed = self.embeds.NOT_PLAYING()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
@ -19,4 +19,7 @@ class ResumeHandler(AbstractHandler):
|
||||
queue = processInfo.getQueue()
|
||||
queue.put(command)
|
||||
|
||||
return HandlerResponse(self.ctx)
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
embed = self.embeds.NOT_PLAYING()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
@ -25,4 +25,8 @@ class SkipHandler(AbstractHandler):
|
||||
command = VCommands(VCommandsType.SKIP, None)
|
||||
queue = processInfo.getQueue()
|
||||
queue.put(command)
|
||||
return HandlerResponse(self.ctx)
|
||||
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
embed = self.embeds.NOT_PLAYING()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
@ -20,3 +20,6 @@ class StopHandler(AbstractHandler):
|
||||
queue.put(command)
|
||||
|
||||
return HandlerResponse(self.ctx)
|
||||
else:
|
||||
embed = self.embeds.NOT_PLAYING()
|
||||
return HandlerResponse(self.ctx, embed)
|
||||
|
||||
@ -56,10 +56,6 @@ class Downloader:
|
||||
except DownloadError:
|
||||
raise DownloadingError()
|
||||
|
||||
async def preload(self, songs: List[Song]) -> None:
|
||||
for song in songs:
|
||||
asyncio.ensure_future(self.download_song(song))
|
||||
|
||||
@run_async
|
||||
def extract_info(self, url: str) -> List[dict]:
|
||||
if url == '':
|
||||
|
||||
@ -254,7 +254,7 @@ class PlayerProcess(Process):
|
||||
# Lock to work with Player
|
||||
with self.__playerLock:
|
||||
if self.__guild.voice_client is not None and self.__playing:
|
||||
self.__playing = None
|
||||
self.__playing = False
|
||||
self.__guild.voice_client.stop()
|
||||
|
||||
async def __forceStop(self) -> None:
|
||||
|
||||
@ -164,7 +164,7 @@ class Embeds:
|
||||
|
||||
def COMMAND_NOT_FOUND(self) -> Embed:
|
||||
embed = Embed(
|
||||
title=self.__messages.ERROR_TITLE,
|
||||
title=self.__messages.COMMAND_NOT_FOUND_TITLE,
|
||||
description=self.__messages.COMMAND_NOT_FOUND,
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user