Compare commits

...

6 Commits

6 changed files with 33 additions and 23 deletions

View File

@@ -54,16 +54,17 @@ class Song:
timestamp=self.trigger_message.edited_at or self.trigger_message.created_at, timestamp=self.trigger_message.edited_at or self.trigger_message.created_at,
) )
uploader_value = None
if self.player.uploader_url: if self.player.uploader_url:
embed.add_field( if self.player.uploader:
name="Uploader", uploader_value = f"[{self.player.uploader}]({self.player.uploader_url})"
value=f"[{self.player.uploader}]({self.player.uploader_url})", else:
) uploader_value = self.player.uploader_url
elif self.player.uploader: elif self.player.uploader:
embed.add_field( uploader_value = self.player.uploader
name="Uploader",
value=self.player.uploader, if uploader_value:
) embed.add_field(name="Uploader", value=uploader_value)
if self.player.like_count: if self.player.like_count:
embed.add_field(name="Likes", value=f"{self.player.like_count:,}") embed.add_field(name="Likes", value=f"{self.player.like_count:,}")
if self.player.view_count: if self.player.view_count:
@@ -77,7 +78,7 @@ class Song:
embed.set_image(self.player.thumbnail_url) embed.set_image(self.player.thumbnail_url)
embed.set_footer( embed.set_footer(
text=f"queued by {self.trigger_message.author.name}", text=f"Queued by {self.trigger_message.author.name}",
icon_url=( icon_url=(
self.trigger_message.author.avatar.url self.trigger_message.author.avatar.url
if self.trigger_message.author.avatar if self.trigger_message.author.avatar

View File

@@ -90,13 +90,13 @@ async def pause(message):
async def fast_forward(message): async def fast_forward(message):
tokens = commands.tokenize(message.content) tokens = commands.tokenize(message.content)
parser = arguments.ArgumentParser(tokens[0], "skip current sponsorblock segment") parser = arguments.ArgumentParser(tokens[0], "skip the current sponsorblock segment")
parser.add_argument( parser.add_argument(
"-s", "-s",
"--seconds", "--seconds",
nargs="?", nargs="?",
type=lambda v: arguments.range_type(v, lower=0, upper=300), type=lambda v: arguments.range_type(v, lower=0, upper=300),
help="the amount of seconds to fast forward instead", help="the number of seconds to fast forward instead",
) )
if not (args := await parser.parse_args(message, tokens)): if not (args := await parser.parse_args(message, tokens)):
return return

View File

@@ -8,7 +8,7 @@ import audio
import commands import commands
import utils import utils
from constants import EMBED_COLOR from constants import EMBED_COLOR
from state import client, players from state import client, players, trusted_users
from .playback import resume from .playback import resume
from .utils import command_allowed, ensure_joined, play_next from .utils import command_allowed, ensure_joined, play_next
@@ -147,6 +147,7 @@ async def queue_or_play(message, edited=False):
) )
>= 5 >= 5
and not len(message.guild.voice_client.channel.members) == 2 and not len(message.guild.voice_client.channel.members) == 2
and message.author.id not in trusted_users
): ):
await utils.reply( await utils.reply(
message, message,

27
core.py
View File

@@ -3,6 +3,7 @@ import contextlib
import importlib import importlib
import inspect import inspect
import io import io
import signal
import textwrap import textwrap
import time import time
import traceback import traceback
@@ -59,17 +60,8 @@ async def on_message(message, edited=False):
match matched: match matched:
case C.RELOAD if message.author.id in OWNERS: case C.RELOAD if message.author.id in OWNERS:
reloaded_modules = set()
start = time.time() start = time.time()
reloaded_modules = reload()
rreload(reloaded_modules, __import__("core"))
rreload(reloaded_modules, __import__("extra"))
for module in filter(
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
globals().values(),
):
rreload(reloaded_modules, module)
end = time.time() end = time.time()
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",
@@ -186,3 +178,18 @@ def rreload(reloaded_modules, module):
if "__reload_module__" in dir(module): if "__reload_module__" in dir(module):
module.__reload_module__() module.__reload_module__()
def reload(*_):
reloaded_modules = set()
rreload(reloaded_modules, __import__("core"))
rreload(reloaded_modules, __import__("extra"))
for module in filter(
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
globals().values(),
):
rreload(reloaded_modules, module)
return reloaded_modules
signal.signal(signal.SIGUSR1, reload)

View File

@@ -5,4 +5,4 @@ disnake_paginator
psutil psutil
PyNaCl PyNaCl
youtube_transcript_api youtube_transcript_api
yt-dlp yt-dlp[default] @ https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz

View File

@@ -17,3 +17,4 @@ message_responses = LimitedSizeDict()
players = {} players = {}
sponsorblock_cache = LimitedSizeDict() sponsorblock_cache = LimitedSizeDict()
start_time = time.time() start_time = time.time()
trusted_users = []