cleanup / respect allergies
This commit is contained in:
32
cogs/sing.py
32
cogs/sing.py
@ -1,6 +1,3 @@
|
||||
#!/usr/bin/env python3.12
|
||||
# pylint: disable=bare-except, broad-exception-caught, global-statement, invalid-name
|
||||
|
||||
import traceback
|
||||
import logging
|
||||
from typing import Optional, Union
|
||||
@ -12,7 +9,6 @@ from util.sing_util import Utility
|
||||
from discord.ext import bridge, commands
|
||||
from disc_havoc import Havoc
|
||||
|
||||
|
||||
BOT_CHANIDS = []
|
||||
|
||||
class Sing(commands.Cog):
|
||||
@ -73,11 +69,15 @@ class Sing(commands.Cog):
|
||||
(search_artist, search_song, search_subsearch) = parsed
|
||||
|
||||
# await ctx.respond(f"So, {search_song} by {search_artist}? Subsearch: {search_subsearch} I will try...") # Commented, useful for debugging
|
||||
search_result: list[str] = await self.utility.lyric_search(search_artist, search_song,
|
||||
search_result: Optional[list] = await self.utility.lyric_search(search_artist, search_song,
|
||||
search_subsearch)
|
||||
|
||||
if not search_result:
|
||||
await ctx.respond("ERR: No search result.")
|
||||
return
|
||||
|
||||
if len(search_result) == 1:
|
||||
return await ctx.respond(search_result[0].strip())
|
||||
return await ctx.respond("ERR: Not found!")
|
||||
if not isinstance(search_result[0], tuple):
|
||||
return # Invalid data type
|
||||
(
|
||||
@ -111,11 +111,12 @@ class Sing(commands.Cog):
|
||||
embed.set_footer(text=footer)
|
||||
embeds.append(embed)
|
||||
await ctx.respond(embed=embeds[0])
|
||||
for embed in embeds[1:]:
|
||||
await ctx.send(embed=embed)
|
||||
for _embed in embeds[1:]:
|
||||
if isinstance(_embed, discord.Embed):
|
||||
await ctx.send(embed=_embed)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return await ctx.respond(f"ERR: {str(e)}")
|
||||
await ctx.respond(f"ERR: {str(e)}")
|
||||
|
||||
@commands.user_command(name="Sing")
|
||||
async def sing_context_menu(self, ctx, member: discord.Member) -> None:
|
||||
@ -151,15 +152,18 @@ 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
|
||||
search_result: list = await self.utility.lyric_search(search_artist, search_song,
|
||||
search_result: Optional[list] = await self.utility.lyric_search(search_artist, search_song,
|
||||
search_subsearch)
|
||||
|
||||
if len(search_result) == 1:
|
||||
return await ctx.send(search_result[0].strip())
|
||||
if not search_result:
|
||||
await ctx.respond("ERR: No search result")
|
||||
return
|
||||
|
||||
if isinstance(search_result[0], str):
|
||||
return await ctx.send("ERR: No search result") # Error message from API
|
||||
|
||||
(search_result_artist, search_result_song, search_result_src,
|
||||
search_result_confidence, search_result_time_taken) = search_result[0] # First index is a tuple
|
||||
search_result_wrapped: list[str] = search_result[1] # Second index is the wrapped lyrics
|
||||
search_result_wrapped: list = search_result[1] # Second index is the wrapped lyrics
|
||||
search_result_wrapped_short: list[str] = search_result[2] # Third index is shortened lyrics
|
||||
|
||||
if not IS_SPAMCHAN:
|
||||
|
Reference in New Issue
Block a user