From 436755f884c051739cdb3cc81b466e62fbc1e417 Mon Sep 17 00:00:00 2001 From: codey Date: Tue, 25 Mar 2025 06:25:04 -0400 Subject: [PATCH] better shortened lyrics for non-botspam chans --- cogs/meme.py | 5 +++++ cogs/sing.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cogs/meme.py b/cogs/meme.py index 4476aa7..3141567 100644 --- a/cogs/meme.py +++ b/cogs/meme.py @@ -196,6 +196,11 @@ class Meme(commands.Cog): except: pass await db_conn.commit() + try: + await self.update_meme_lb() + except Exception as e: + logging.info("Failed to update meme leaderboard following increment: %s", + str(e)) async def init_meme_leaderboard(self) -> None: diff --git a/cogs/sing.py b/cogs/sing.py index 4532678..7cd864b 100644 --- a/cogs/sing.py +++ b/cogs/sing.py @@ -62,7 +62,7 @@ class Sing(commands.Cog): return await ctx.respond("**Error**: No song specified, no activity found to read.") if interaction: - await ctx.respond("*Searching...*", ephemeral=True) # Must respond to interactions within 3 seconds, per Discord + await ctx.respond("*Searching...*") # Must respond to interactions within 3 seconds, per Discord parsed = self.utility.parse_song_input(song, activity) @@ -88,7 +88,9 @@ class Sing(commands.Cog): search_result_wrapped: list[str] = search_result[1] # Second index is the wrapped lyrics search_result_wrapped_short: list[str] = search_result[2] # Third is short wrapped lyrics if not ctx.channel.id in BOT_CHANIDS: - search_result_wrapped = search_result_wrapped_short # Replace with shortened lyrics for non spamchans + short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans + short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip()) + return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}") embeds: list[Optional[discord.Embed]] = [] embed_url: str = f"[on codey.lol](https://codey.lol/#{urllib.parse.quote(search_artist)}/{urllib.parse.quote(search_song)})" c: int = 0 @@ -152,7 +154,7 @@ class Sing(commands.Cog): if isinstance(parsed, tuple): (search_artist, search_song, search_subsearch) = parsed - await ctx.respond("*Searching...*", ephemeral=True) # Must respond to interactions within 3 seconds, per Discord + await ctx.respond("*Searching...*") # Must respond to interactions within 3 seconds, per Discord search_result: Optional[list] = await self.utility.lyric_search(search_artist, search_song, search_subsearch) if not search_result: @@ -170,7 +172,9 @@ class Sing(commands.Cog): search_result_wrapped_short: list[str] = search_result[2] # Third index is shortened lyrics if not IS_SPAMCHAN: - search_result_wrapped = search_result_wrapped_short # Swap for shortened lyrics if not spam chan + short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans + short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip()) + return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}") embeds: list[Optional[discord.Embed]] = [] c: int = 0