From abd6da7134bab912f680d35a82f728626eaee0cf Mon Sep 17 00:00:00 2001 From: LBlend Date: Wed, 14 Dec 2022 01:52:57 +0100 Subject: [PATCH] (correctly) add localization support to lyrics command --- musicbot/cogs/music/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/musicbot/cogs/music/__init__.py b/musicbot/cogs/music/__init__.py index 810178b..de3974b 100644 --- a/musicbot/cogs/music/__init__.py +++ b/musicbot/cogs/music/__init__.py @@ -637,7 +637,7 @@ class Music(commands.Cog): """ Search for lyrics of a song """ # Check for API key if not (genius_access_token := self.bot.APIkeys.get('genius')): - return await ctx.send('{errors.missing_api_key}') + return await ctx.send(ctx.localizer.format_str('{history.title}')) # Extract all arguments into a single string query = ' '.join(query) @@ -646,7 +646,7 @@ class Music(commands.Cog): if not query: player = self.get_player(ctx.guild) if not player.is_playing: - return await ctx.send('{nothing_playing}') + return await ctx.send(ctx.localizer.format_str('{nothing_playing}')) query = player.current.title # Filter out unwanted words to improve chances of finding the correct song @@ -665,7 +665,8 @@ class Music(commands.Cog): header = {} if scrape else {'Authorization': f'Bearer {genius_access_token}'} async with self.bot.session.get(url, headers=header) as r: if r.status != 200: - embed = discord.Embed(description="{errors.error_occurred}", color=0xFF0000) + embed = discord.Embed(description=ctx.localizer.format_str('{errors.error_occurred}'), + color=0xFF0000) await status_msg.edit(embed=embed) return if scrape: @@ -687,7 +688,7 @@ class Music(commands.Cog): break song_url = song['url'] except KeyError: - embed = discord.Embed(description='{nothing_found}', color=0xFF0000) + embed = discord.Embed(description=ctx.localizer.format_str('{nothing_found}'), color=0xFF0000) return await status_msg.edit(embed=embed) # Scrape the lyrics from the song page