reformat/refactor

This commit is contained in:
2025-04-26 21:59:46 -04:00
parent 5bde6ac880
commit a433dc2fb5
14 changed files with 150 additions and 107 deletions

View File

@ -36,7 +36,8 @@ class Radio(commands.Cog):
def predicate(ctx):
try:
return ctx.channel.id == 1221615558492029050
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return False
@ -71,10 +72,11 @@ class Radio(commands.Cog):
logging.debug("Failed to cancel radio_state_loop: %s", str(e))
self.radio_state_loop.start()
logging.info("radio_state_loop task started!")
except:
logging.critical("Could not start task...")
except Exception as e:
logging.critical("Could not start task... Exception: %s", str(e))
traceback.print_exc()
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return
@ -85,8 +87,11 @@ class Radio(commands.Cog):
(radio_guild, radio_chan) = self.channels["sfm"]
try:
vc: discord.VoiceProtocol = self.bot.voice_clients[-1]
except:
logging.debug("No voice client, establishing new VC connection...")
except Exception as e:
logging.debug(
"No voice client, establishing new VC connection... (Exception: %s)",
str(e),
)
guild: Optional[discord.Guild] = self.bot.get_guild(radio_guild)
if not guild:
return
@ -105,8 +110,8 @@ class Radio(commands.Cog):
source: discord.FFmpegAudio = discord.FFmpegOpusAudio(
self.STREAM_URL, before_options="-timeout 3000000"
)
vc.play(
source, # type: ignore
vc.play( # type: ignore
source,
after=lambda e: logging.info("Error: %s", e) if e else None,
)
# Get Now Playing
@ -118,7 +123,8 @@ class Radio(commands.Cog):
type=discord.ActivityType.listening, name=np_track
)
)
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
@bridge.bridge_command()