(correctly) add localization support to lyrics command

This commit is contained in:
LBlend committed 2022-12-14 01:52:57 +01:00
1 parent bcc59839dd
commit abd6da7134
1 file changed
+5 -4
+5 -4
View File
@@ -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