diff --git a/src/cogs/music.py b/src/cogs/music.py index 3baa900..569abc4 100644 --- a/src/cogs/music.py +++ b/src/cogs/music.py @@ -476,16 +476,20 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Déjà connecté.") channel = getattr(ctx.author.voice, 'channel', channel) if channel is None: + if fromSlash != True: + await addReaction(ctx.message, 2) raise NoChannelProvided await player.connect(channel.id, self_deaf = True) await ctx.send(f":thumbsup: **Connecté à __{channel.name}__**") if fromSlash != True: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) @cog_ext.cog_slash(name="join", description = "Se connecte au salon vocal.") async def _connect(self, ctx, channel = None): return await self.connect(ctx = ctx, channel = channel, fromSlash = True) @@ -496,6 +500,8 @@ class Music(commands.Cog, wavelink.WavelinkMixin): _, fromSlash, _ = isSlash(multipleArgsToTuple(_getframe(0))) noSoundFound = "Aucun son n'a été trouvée avec cette requête." if query == None: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, noSoundFound, delete_after=15) player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) @@ -504,8 +510,12 @@ class Music(commands.Cog, wavelink.WavelinkMixin): try: channel = getattr(ctx.author.voice, 'channel') except: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Tu n'es connecté à aucun salon vocal.") if channel is None: + if fromSlash != True: + await addReaction(ctx.message, 2) raise NoChannelProvided await self.connect(ctx = ctx, channel = channel, fromSlash = True) @@ -515,6 +525,8 @@ class Music(commands.Cog, wavelink.WavelinkMixin): tracks = await self.bot.wavelink.get_tracks(query) if not tracks: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, noSoundFound, delete_after=15) if isinstance(tracks, wavelink.TrackPlaylist): @@ -534,7 +546,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): await player.do_next() if fromSlash != True: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) @cog_ext.cog_slash(name="play", description = "Joue ou met dans la file d'attente le son demandé.") async def _play(self, ctx, son): return await self.play(ctx = ctx, query = son, fromSlash = True) @@ -546,10 +558,12 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if self.is_privileged(ctx): await ctx.send(f"{ctx.author.mention} a mis la musique en pause.", delete_after=10) @@ -577,10 +591,12 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique en pause n'est en cours.") if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if self.is_privileged(ctx): await ctx.send(f"{ctx.author.mention} a relancé la musique.", delete_after=10) @@ -608,10 +624,12 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if self.is_privileged(ctx) or ctx.author == player.current.requester: await ctx.send(f"{ctx.author.mention} passe le son.", delete_after=10) @@ -639,10 +657,12 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if self.is_privileged(ctx): await ctx.send(f"{ctx.author.mention} a déconnecté le bot et a supprimé la file d'attente.", delete_after=10) @@ -667,21 +687,27 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if not self.is_privileged(ctx): + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Seuls le DJ ou les admins peuvent modifier le volume.") if not vol: await mySendHidden(ctx, fromSlash, f"Le volume est actuellement réglé à **{player.volume}%**.") if fromSlash != True: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) else: if not 0 < vol < 101: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Veuillez saisir une valeur comprise entre 1 et 100.") if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) await player.set_volume(vol) await ctx.send(f"Volume réglé sur **{vol}%** par {ctx.author.mention}", delete_after=7) @@ -696,13 +722,17 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if player.queue.qsize() < 3: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Ajoutez d'autres sons à la file d'attente avant de les mélanger (3 minimum).", delete_after=15) if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if self.is_privileged(ctx): await ctx.send(f"{ctx.author.mention} a mélangé la liste de lecture.", delete_after=10) @@ -761,9 +791,13 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if not self.is_privileged(ctx): + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Seul le DJ ou les admins peuvent modifier l'égaliseur.") eqs = {'flat': wavelink.Equalizer.flat(), @@ -774,12 +808,14 @@ class Music(commands.Cog, wavelink.WavelinkMixin): eq = eqs.get(equalizer.lower(), None) if not eq: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, f"EQ non valide fourni.\nEQs valides : {', '.join(eqs.keys())}") await ctx.send(f"Changement d'état de l'égaliseur en `{equalizer}` par {ctx.author.mention}.", delete_after=15) await player.set_eq(eq) if fromSlash != True: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) @cog_ext.cog_slash(name="equalizer", description = "Change l'égaliseur de musique. (flat/boost/metal/piano)") async def _equalizer(self, ctx, equalizer: str): return await self.equalizer(ctx = ctx, equalizer = equalizer, fromSlash = True) @@ -791,9 +827,13 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if player.queue.qsize() == 0: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Il n'y a plus de sons dans la file d'attente.", delete_after=15) entries = [track.title for track in player.queue._queue] @@ -803,7 +843,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): if fromSlash: await ctx.send("Affichage de la liste ci-dessous.", hidden = True) else: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) await paginator.start(ctx) @cog_ext.cog_slash(name="queue", description = "Affiche les sons en attente.") async def _queue(self, ctx,): @@ -816,13 +856,15 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") await player.invoke_controller() if fromSlash: await mySendHidden(ctx, fromSlash, "Mise à jour effectuée.") else: - return await addReaction(ctx.message, 1) + return await addReaction(ctx.message, 0) @cog_ext.cog_slash(name="nowplaying", description = "Met à jour l'embed qui affiche les informations sur la chanson en cours si besoin.") async def _nowplaying(self, ctx,): return await self.nowplaying(ctx = ctx, fromSlash = True) @@ -834,24 +876,34 @@ 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 != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucune musique n'est en cours.") if not self.is_privileged(ctx): + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Seuls les admins et le DJ peuvent utiliser cette commande.", delete_after=15) members = self.bot.get_channel(int(player.channel_id)).members if member and member not in members: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, f"{member} n'est actuellement pas dans le salon vocal, et ne peut donc pas devenir DJ.", delete_after=15) if member and member == player.dj: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Cette personne est déjà DJ.", delete_after=15) if len(members) <= 2: + if fromSlash != True: + await addReaction(ctx.message, 2) return await mySendHidden(ctx, fromSlash, "Aucun autre membre à qui donner le rôle de DJ.", delete_after=15) if fromSlash != True: - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if member: player.dj = member @@ -876,22 +928,24 @@ class Music(commands.Cog, wavelink.WavelinkMixin): if not song: song = re.sub(r"(\ )?\(.*\)", "", player.current.title) if " romanized" in song: - message = await ctx.send(f":mag: **Cherche les paroles romanisées de ** `{song.replace(' romanized', '')}`") + message = await ctx.send(f":mag: **Cherche les paroles romanisées de** `{song.replace(' romanized', '')}`") else: - message = await ctx.send(f":mag: **Cherche les paroles de ** `{song}`") + message = await ctx.send(f":mag: **Cherche les paroles de** `{song}`") temps_requete = int(round(nowCustom() * 1000)) song_genius = genius.search_song(song) couleur_embed = discord.Colour.random() try: paroles = song_genius.lyrics except: - await addReaction(ctx.message, 2) + if fromSlash != True: + await addReaction(ctx.message, 2) return await message.edit(content = f"Pas de résultats trouvés pour `{song}`.") paroles = re.sub(r"3?EmbedShare URLCopyEmbedCopy", "", paroles) # Fix temporaire bug Genius lignetotal = "" premierembed = True if len(paroles) > 7500: - await addReaction(ctx.message, 2) + if fromSlash != True: + await addReaction(ctx.message, 3) return await message.edit(content = f"Les paroles sont trop longues pour être affichés (lien vers la page des paroles : {song_genius.url}).") title_first_embed = f"Paroles de {song_genius.title} par {song_genius.artist}." desc_first_embed = f"[Lien vers les paroles sur le site]({song_genius.url})" @@ -915,7 +969,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin): temps_requete = int(round(nowCustom() * 1000)) - temps_requete footer_embed = f"Pour {userOrNick(ctx.author)} par Genius en {round(temps_requete / 1000, 2)} s." - await addReaction(ctx.message, 1) + await addReaction(ctx.message, 0) if premierembed == True: premierembed = False embed = discord.Embed(title = title_first_embed, description = f"{desc_first_embed}{lignetotal}", color = couleur_embed) @@ -926,7 +980,8 @@ class Music(commands.Cog, wavelink.WavelinkMixin): embed.set_footer(icon_url = ctx.author.avatar_url, text = footer_embed) return await ctx.send(embed = embed) else: - await addReaction(ctx.message, 2) + if fromSlash != True: + await addReaction(ctx.message, 2) await mySendHidden(ctx, fromSlash, f"Aucune musique demandé... `{ctx.prefix}lyrics/l/lyrics `.") @cog_ext.cog_slash(name="lyrics", description = "Affiche les paroles de la musique en cours, ou de la chanson spécifiée.") async def __lyrics(self, ctx, song: str): @@ -937,4 +992,4 @@ class Music(commands.Cog, wavelink.WavelinkMixin): player: Player = self.bot.wavelink.get_player(guild_id=ctx.guild.id, cls=Player, context=ctx) if not song and player.is_playing: song = re.sub(r"(\ )?\(.*\)", "", player.current.title) - await ctx.invoke(self.client.get_command("lyrics"), song = f"{song} romanized" if song else song) + await ctx.invoke(self.bot.get_command("lyrics"), song = f"{song} romanized" if song else song)