Compare commits

..

5 Commits

Author SHA1 Message Date
22249ecf7a
refactor: remove useless debug checks
Debug messages shouldn't be printed in the first place if debug isn't on.
2025-02-13 16:31:52 -05:00
5610fc7acd
refactor: minor cleanups 2025-02-13 16:31:30 -05:00
c73260badb
feat(commands): add c as alias for current 2025-02-13 16:28:51 -05:00
2645f33940
fix: reload all util modules 2025-02-12 19:04:16 -05:00
8d76a107c5
refactor(utils/cooldown): ignore owners 2025-02-12 19:02:50 -05:00
5 changed files with 22 additions and 15 deletions

View File

@ -30,10 +30,13 @@ class Command(Enum):
@lru_cache
def match_token(token: str) -> list[Command]:
if token.lower() == "r":
return [Command.RELOAD]
elif token.lower() == "s":
return [Command.SKIP]
match token.lower():
case "r":
return [Command.RELOAD]
case "s":
return [Command.SKIP]
case "c":
return [Command.CURRENT]
if exact_match := list(
filter(

View File

@ -45,6 +45,8 @@ RELOADABLE_MODULES = [
"sponsorblock",
"tasks",
"utils",
"utils.common",
"utils.discord",
"voice",
"yt_dlp",
"yt_dlp.version",

14
core.py
View File

@ -48,11 +48,12 @@ async def on_message(message, edited=False):
try:
if (cooldowns := command_cooldowns.get(message.author.id)) and not edited:
cur_time = time.time()
if (end_time := cooldowns.get(matched)) and round(end_time - cur_time) > 0:
if (end_time := cooldowns.get(matched)) and (
remaining_time := round(end_time - time.time()) > 0
):
await utils.reply(
message,
f"please wait **{utils.format_duration(round(end_time - cur_time), natural=True)}** before using this command again!",
f"please wait **{utils.format_duration(remaining_time, natural=True)}** before using this command again!",
)
return
@ -70,10 +71,9 @@ async def on_message(message, edited=False):
rreload(reloaded_modules, module)
end = time.time()
if __debug__:
debug(
f"reloaded {len(reloaded_modules)} modules in {round(end - start, 2)}s"
)
debug(
f"reloaded {len(reloaded_modules)} modules in {round(end - start, 2)}s"
)
await utils.add_check_reaction(message)

View File

@ -19,8 +19,7 @@ async def cleanup():
targets.append(guild_id)
for target in targets:
del players[target]
if __debug__:
debug(f"cleanup removed {len(targets)} empty players")
debug(f"cleanup removed {len(targets)} empty players")
if (
not idle_tracker["is_idle"]

View File

@ -5,10 +5,14 @@ from logging import error, info
import disnake
import commands
from constants import OWNERS
from state import command_cooldowns, message_responses
def cooldown(message, cooldown_time: int):
if message.author.id in OWNERS:
return
possible_commands = commands.match(message.content)
if not possible_commands or len(possible_commands) > 1:
return
@ -86,8 +90,7 @@ class ChannelResponseWrapper:
self.sent_message = None
async def send_message(self, **kwargs):
if "ephemeral" in kwargs:
del kwargs["ephemeral"]
kwargs.pop("ephemeral", None)
self.sent_message = await reply(self.message, **kwargs)
async def edit_message(self, content=None, embed=None, view=None):