mirror of
https://github.com/weyne85/discord_music_bot.git
synced 2025-10-29 16:58:27 +00:00
Finishing PrevController
This commit is contained in:
parent
f09568bd69
commit
f9b46e13ff
@ -1,7 +1,7 @@
|
||||
from discord.ext.commands import Context
|
||||
from discord import Client
|
||||
from Controllers.AbstractController import AbstractController
|
||||
from Exceptions.Exceptions import ImpossibleMove, UnknownError
|
||||
from Exceptions.Exceptions import BadCommandUsage, ImpossibleMove, UnknownError
|
||||
from Controllers.ControllerResponse import ControllerResponse
|
||||
|
||||
|
||||
@ -27,6 +27,11 @@ class PrevController(AbstractController):
|
||||
embed = self.embeds.UNKNOWN_ERROR()
|
||||
return ControllerResponse(self.ctx, embed, error)
|
||||
|
||||
if self.player.playlist.looping_all or self.player.playlist.looping_one:
|
||||
error = BadCommandUsage()
|
||||
embed = self.embeds.FAIL_DUE_TO_LOOP_ON()
|
||||
return ControllerResponse(self.ctx, embed, error)
|
||||
|
||||
await self.player.play_prev(self.ctx)
|
||||
|
||||
def __user_connected(self) -> bool:
|
||||
|
||||
@ -5,15 +5,12 @@ from discord.ext.commands import Context
|
||||
from datetime import timedelta
|
||||
from Music.Downloader import Downloader
|
||||
from Music.Playlist import Playlist
|
||||
from Music.Searcher import Searcher
|
||||
from Music.Song import Song
|
||||
from Music.Types import Provider
|
||||
from Utils.Utils import *
|
||||
from Utils.Utils import Timer
|
||||
|
||||
|
||||
class Player(commands.Cog):
|
||||
def __init__(self, bot: Client, guild: Guild):
|
||||
self.__searcher: Searcher = Searcher()
|
||||
self.__down: Downloader = Downloader()
|
||||
self.__playlist: Playlist = Playlist()
|
||||
self.__bot: Client = bot
|
||||
@ -42,24 +39,8 @@ class Player(commands.Cog):
|
||||
await self.__play_music(ctx, first_song)
|
||||
|
||||
async def play_prev(self, ctx: Context) -> None:
|
||||
if self.__playlist.looping_one or self.__playlist.looping_all: # Do not allow play if loop
|
||||
embed = Embed(
|
||||
title=self.__config.SONG_PLAYER,
|
||||
description=self.__config.LOOP_ON,
|
||||
colour=self.__config.COLOURS['blue']
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
return None
|
||||
|
||||
song = self.__playlist.prev_song() # Prepare the prev song to play again
|
||||
if song == None:
|
||||
embed = Embed(
|
||||
title=self.__config.SONG_PLAYER,
|
||||
description=self.__config.NOT_PREVIOUS,
|
||||
colour=self.__config.COLOURS['blue']
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
song = self.__playlist.prev_song()
|
||||
if song is not None:
|
||||
if self.__guild.voice_client.is_playing() or self.__guild.voice_client.is_paused():
|
||||
# Will forbidden next_song to execute after stopping current player
|
||||
self.__force_stop = True
|
||||
|
||||
@ -180,7 +180,7 @@ class Embeds:
|
||||
embed = Embed(
|
||||
title=self.__config.SONG_PLAYER,
|
||||
description=self.__config.LOOP_ON,
|
||||
colour=self.__colors.BLUE
|
||||
colour=self.__colors.BLACK
|
||||
)
|
||||
return embed
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user