Compare commits
5 Commits
8ee7693b91
...
22249ecf7a
Author | SHA1 | Date | |
---|---|---|---|
22249ecf7a | |||
5610fc7acd | |||
c73260badb | |||
2645f33940 | |||
8d76a107c5 |
@ -30,10 +30,13 @@ class Command(Enum):
|
|||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def match_token(token: str) -> list[Command]:
|
def match_token(token: str) -> list[Command]:
|
||||||
if token.lower() == "r":
|
match token.lower():
|
||||||
|
case "r":
|
||||||
return [Command.RELOAD]
|
return [Command.RELOAD]
|
||||||
elif token.lower() == "s":
|
case "s":
|
||||||
return [Command.SKIP]
|
return [Command.SKIP]
|
||||||
|
case "c":
|
||||||
|
return [Command.CURRENT]
|
||||||
|
|
||||||
if exact_match := list(
|
if exact_match := list(
|
||||||
filter(
|
filter(
|
||||||
|
@ -45,6 +45,8 @@ RELOADABLE_MODULES = [
|
|||||||
"sponsorblock",
|
"sponsorblock",
|
||||||
"tasks",
|
"tasks",
|
||||||
"utils",
|
"utils",
|
||||||
|
"utils.common",
|
||||||
|
"utils.discord",
|
||||||
"voice",
|
"voice",
|
||||||
"yt_dlp",
|
"yt_dlp",
|
||||||
"yt_dlp.version",
|
"yt_dlp.version",
|
||||||
|
8
core.py
8
core.py
@ -48,11 +48,12 @@ async def on_message(message, edited=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if (cooldowns := command_cooldowns.get(message.author.id)) and not edited:
|
if (cooldowns := command_cooldowns.get(message.author.id)) and not edited:
|
||||||
cur_time = time.time()
|
if (end_time := cooldowns.get(matched)) and (
|
||||||
if (end_time := cooldowns.get(matched)) and round(end_time - cur_time) > 0:
|
remaining_time := round(end_time - time.time()) > 0
|
||||||
|
):
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
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
|
return
|
||||||
|
|
||||||
@ -70,7 +71,6 @@ async def on_message(message, edited=False):
|
|||||||
rreload(reloaded_modules, module)
|
rreload(reloaded_modules, module)
|
||||||
|
|
||||||
end = time.time()
|
end = time.time()
|
||||||
if __debug__:
|
|
||||||
debug(
|
debug(
|
||||||
f"reloaded {len(reloaded_modules)} modules in {round(end - start, 2)}s"
|
f"reloaded {len(reloaded_modules)} modules in {round(end - start, 2)}s"
|
||||||
)
|
)
|
||||||
|
1
tasks.py
1
tasks.py
@ -19,7 +19,6 @@ async def cleanup():
|
|||||||
targets.append(guild_id)
|
targets.append(guild_id)
|
||||||
for target in targets:
|
for target in targets:
|
||||||
del players[target]
|
del players[target]
|
||||||
if __debug__:
|
|
||||||
debug(f"cleanup removed {len(targets)} empty players")
|
debug(f"cleanup removed {len(targets)} empty players")
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -5,10 +5,14 @@ from logging import error, info
|
|||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import commands
|
import commands
|
||||||
|
from constants import OWNERS
|
||||||
from state import command_cooldowns, message_responses
|
from state import command_cooldowns, message_responses
|
||||||
|
|
||||||
|
|
||||||
def cooldown(message, cooldown_time: int):
|
def cooldown(message, cooldown_time: int):
|
||||||
|
if message.author.id in OWNERS:
|
||||||
|
return
|
||||||
|
|
||||||
possible_commands = commands.match(message.content)
|
possible_commands = commands.match(message.content)
|
||||||
if not possible_commands or len(possible_commands) > 1:
|
if not possible_commands or len(possible_commands) > 1:
|
||||||
return
|
return
|
||||||
@ -86,8 +90,7 @@ class ChannelResponseWrapper:
|
|||||||
self.sent_message = None
|
self.sent_message = None
|
||||||
|
|
||||||
async def send_message(self, **kwargs):
|
async def send_message(self, **kwargs):
|
||||||
if "ephemeral" in kwargs:
|
kwargs.pop("ephemeral", None)
|
||||||
del kwargs["ephemeral"]
|
|
||||||
self.sent_message = await reply(self.message, **kwargs)
|
self.sent_message = await reply(self.message, **kwargs)
|
||||||
|
|
||||||
async def edit_message(self, content=None, embed=None, view=None):
|
async def edit_message(self, content=None, embed=None, view=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user