diff --git a/src/cogs/music.py b/src/cogs/music.py index c8058a9..531a26b 100644 --- a/src/cogs/music.py +++ b/src/cogs/music.py @@ -475,8 +475,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if player.is_connected: - if fromSlash: - await ctx.send("Déjà connecté.", hidden = True) + mySendHidden(ctx, fromSlash, "Déjà connecté.") return channel = getattr(ctx.author.voice, 'channel', channel) @@ -499,8 +498,11 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) - if not player.is_connected: - channel = getattr(ctx.author.voice, 'channel') + if not player.is_connected: + try: + channel = getattr(ctx.author.voice, 'channel') + except: + return await mySendHidden(ctx, fromSlash, "Tu n'es connecté à aucun salon vocal.") if channel is None: raise NoChannelProvided await self.connect(ctx = ctx, channel = channel, fromSlash = True) @@ -539,8 +541,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if player.is_paused or not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if self.is_privileged(ctx): @@ -569,8 +570,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_paused or not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique en pause n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique en pause n'est en cours.") return if self.is_privileged(ctx): @@ -599,8 +599,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if self.is_privileged(ctx) or ctx.author == player.current.requester: @@ -629,13 +628,11 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if self.is_privileged(ctx): await ctx.send(f"{ctx.author.mention} a déconnecter le bot et supprimer la file d'attente.", delete_after=10) - print("x") return await player.teardown() required = self.required(ctx) @@ -660,8 +657,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): return await mySendHidden(ctx, fromSlash, f"Le volume est actuellement réglé à **{player.volume}%**.") if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if not self.is_privileged(ctx): @@ -683,8 +679,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if player.queue.qsize() < 3: @@ -708,7 +703,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): async def _shuffle(self, ctx): return await self.shuffle(ctx = ctx, fromSlash = True) - @commands.command(hidden=True) + @commands.command(hidden = True) async def vol_up(self, ctx: commands.Context): """Command used for volume up button.""" player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) @@ -724,7 +719,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): await player.set_volume(vol) - @commands.command(hidden=True) + @commands.command(hidden = True) async def vol_down(self, ctx: commands.Context): """Command used for volume down button.""" player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) @@ -747,8 +742,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if not self.is_privileged(ctx): @@ -777,8 +771,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if player.queue.qsize() == 0: @@ -788,7 +781,8 @@ class Music(commands.Cog, wavelink.WavelinkMixin): pages = PaginatorSource(entries=entries) paginator = menus.MenuPages(source=pages, timeout=None, delete_message_after=True) - await ctx.send("Affichage de la liste ci-dessous.", hidden = True) + if fromSlash: + await ctx.send("Affichage de la liste ci-dessous.", hidden = True) await paginator.start(ctx) @cog_ext.cog_slash(name="queue", description = "Affiche les sons en attente.") async def _queue(self, ctx,): @@ -801,8 +795,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return await player.invoke_controller() @@ -819,8 +812,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not player.is_connected: - if fromSlash: - await ctx.send("Aucune musique n'est en cours.", hidden = True) + await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") return if not self.is_privileged(ctx):