Compare commits
No commits in common. "062676df264bae3f72858c970f28f3a43e181ea1" and "e7105f18287c4455a52899276c8ebd91353c3587" have entirely different histories.
062676df26
...
e7105f1828
@ -60,7 +60,7 @@ class YTDLSource(PCMVolumeTransformer):
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<YTDLSource title={self.title} original_url={self.original_url} duration={self.duration}>"
|
||||
return f"<YTDLSource title={self.title} original_url=<{self.original_url}> duration={self.duration}>"
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
@ -8,9 +8,9 @@ from yt_dlp import version
|
||||
|
||||
import arguments
|
||||
import commands
|
||||
import utils
|
||||
from constants import EMBED_COLOR
|
||||
from state import client, start_time
|
||||
from utils import format_duration, reply, surround
|
||||
|
||||
|
||||
async def status(message):
|
||||
@ -25,41 +25,41 @@ async def status(message):
|
||||
embed = disnake.Embed(color=EMBED_COLOR)
|
||||
embed.add_field(
|
||||
name="Latency",
|
||||
value=surround(f"{round(client.latency * 1000, 1)} ms"),
|
||||
value=f"```{round(client.latency * 1000, 1)} ms```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Memory",
|
||||
value=surround(f"{round(memory_usage, 1)} MiB"),
|
||||
value=f"```{round(memory_usage, 1)} MiB```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Threads",
|
||||
value=surround(threading.active_count()),
|
||||
value=f"```{threading.active_count()}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Guilds",
|
||||
value=surround(len(client.guilds)),
|
||||
value=f"```{len(client.guilds)}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Members",
|
||||
value=surround(member_count),
|
||||
value=f"```{member_count}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Channels",
|
||||
value=surround(channel_count),
|
||||
value=f"```{channel_count}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Disnake",
|
||||
value=surround(disnake.__version__),
|
||||
value=f"```{disnake.__version__}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="yt-dlp",
|
||||
value=surround(version.__version__),
|
||||
value=f"```{version.__version__}```",
|
||||
)
|
||||
embed.add_field(
|
||||
name="Uptime",
|
||||
value=surround(format_duration(int(time.time() - start_time), short=True)),
|
||||
value=f"```{utils.format_duration(int(time.time() - start_time), short=True)}```",
|
||||
)
|
||||
await reply(message, embed=embed)
|
||||
await utils.reply(message, embed=embed)
|
||||
|
||||
|
||||
async def uptime(message):
|
||||
@ -78,13 +78,15 @@ async def uptime(message):
|
||||
return
|
||||
|
||||
if args.since:
|
||||
await reply(message, f"{round(start_time)}")
|
||||
await utils.reply(message, f"{round(start_time)}")
|
||||
else:
|
||||
await reply(message, f"up {format_duration(int(time.time() - start_time))}")
|
||||
await utils.reply(
|
||||
message, f"up {utils.format_duration(int(time.time() - start_time))}"
|
||||
)
|
||||
|
||||
|
||||
async def ping(message):
|
||||
await reply(
|
||||
await utils.reply(
|
||||
message,
|
||||
embed=disnake.Embed(
|
||||
title="Pong :ping_pong:",
|
||||
@ -95,7 +97,7 @@ async def ping(message):
|
||||
|
||||
|
||||
async def help(message):
|
||||
await reply(
|
||||
await utils.reply(
|
||||
message,
|
||||
", ".join(
|
||||
[f"`{command.value}`" for command in commands.Command.__members__.values()]
|
||||
|
@ -4,11 +4,10 @@ from .utils import command_allowed
|
||||
|
||||
|
||||
async def join(message):
|
||||
if message.author.voice:
|
||||
if message.guild.voice_client:
|
||||
await message.guild.voice_client.move_to(message.channel)
|
||||
else:
|
||||
await message.author.voice.channel.connect()
|
||||
if message.guild.voice_client:
|
||||
return await message.guild.voice_client.move_to(message.channel)
|
||||
elif message.author.voice:
|
||||
await message.author.voice.channel.connect()
|
||||
else:
|
||||
await utils.reply(message, "you are not connected to a voice channel!")
|
||||
return
|
||||
|
@ -3,7 +3,7 @@ import disnake
|
||||
import audio
|
||||
import sponsorblock
|
||||
import utils
|
||||
from constants import EMBED_COLOR, SPONSORBLOCK_CATEGORY_NAMES
|
||||
from constants import EMBED_COLOR
|
||||
from state import players
|
||||
|
||||
from .utils import command_allowed
|
||||
@ -28,12 +28,11 @@ async def sponsorblock_command(message):
|
||||
text = []
|
||||
for segment in video["segments"]:
|
||||
begin, end = map(int, segment["segment"])
|
||||
if (category := segment["category"]) in SPONSORBLOCK_CATEGORY_NAMES:
|
||||
category = SPONSORBLOCK_CATEGORY_NAMES[category]
|
||||
category_name = sponsorblock.CATEGORY_NAMES.get(segment["category"])
|
||||
|
||||
current = "**" if progress >= begin and progress < end else ""
|
||||
text.append(
|
||||
f"{current}`{audio.utils.format_duration(begin)}` - `{audio.utils.format_duration(end)}`: {category}{current}"
|
||||
f"{current}`{audio.utils.format_duration(begin)}` - `{audio.utils.format_duration(end)}`: {category_name if category_name else 'Unknown'}{current}"
|
||||
)
|
||||
|
||||
await utils.reply(
|
||||
|
35
constants.py
35
constants.py
@ -19,11 +19,6 @@ BAR_LENGTH = 35
|
||||
EMBED_COLOR = 0xFF6600
|
||||
OWNERS = [531392146767347712]
|
||||
PREFIX = "%"
|
||||
SPONSORBLOCK_CATEGORY_NAMES = {
|
||||
"music_offtopic": "non-music",
|
||||
"selfpromo": "self promotion",
|
||||
"sponsor": "sponsored",
|
||||
}
|
||||
RELOADABLE_MODULES = [
|
||||
"arguments",
|
||||
"audio",
|
||||
@ -57,21 +52,21 @@ RELOADABLE_MODULES = [
|
||||
"yt_dlp.version",
|
||||
]
|
||||
PUBLIC_FLAGS = {
|
||||
1 << 0: "Discord Employee",
|
||||
1 << 1: "Discord Partner",
|
||||
1 << 2: "HypeSquad Events",
|
||||
1 << 3: "Bug Hunter Level 1",
|
||||
1 << 6: "HypeSquad Bravery",
|
||||
1 << 7: "HypeSquad Brilliance",
|
||||
1 << 8: "HypeSquad Balance",
|
||||
1 << 9: "Early Supporter",
|
||||
1 << 10: "Team User",
|
||||
1 << 14: "Bug Hunter Level 2",
|
||||
1 << 16: "Verified Bot",
|
||||
1 << 17: "Verified Bot Developer",
|
||||
1 << 18: "Discord Certified Moderator",
|
||||
1 << 19: "HTTP Interactions Only",
|
||||
1 << 22: "Active Developer",
|
||||
1: "Discord Employee",
|
||||
2: "Discord Partner",
|
||||
4: "HypeSquad Events",
|
||||
8: "Bug Hunter Level 1",
|
||||
64: "HypeSquad Bravery",
|
||||
128: "HypeSquad Brilliance",
|
||||
256: "HypeSquad Balance",
|
||||
512: "Early Supporter",
|
||||
1024: "Team User",
|
||||
16384: "Bug Hunter Level 2",
|
||||
65536: "Verified Bot",
|
||||
131072: "Verified Bot Developer",
|
||||
262144: "Discord Certified Moderator",
|
||||
524288: "HTTP Interactions Only",
|
||||
4194304: "Active Developer",
|
||||
}
|
||||
BADGE_EMOJIS = {
|
||||
"Discord Employee": "<:DiscordStaff:879666899980546068>",
|
||||
|
@ -1,21 +1,13 @@
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
import aiohttp
|
||||
|
||||
from state import sponsorblock_cache
|
||||
|
||||
categories = json.dumps(
|
||||
[
|
||||
"interaction",
|
||||
"intro",
|
||||
"music_offtopic",
|
||||
"outro",
|
||||
"preview",
|
||||
"selfpromo",
|
||||
"sponsor",
|
||||
]
|
||||
)
|
||||
CATEGORY_NAMES = {
|
||||
"music_offtopic": "non-music",
|
||||
"sponsor": "sponsored",
|
||||
}
|
||||
|
||||
|
||||
async def get_segments(video_id: str):
|
||||
@ -26,7 +18,7 @@ async def get_segments(video_id: str):
|
||||
session = aiohttp.ClientSession()
|
||||
response = await session.get(
|
||||
f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}",
|
||||
params={"categories": categories},
|
||||
params={"categories": '["sponsor", "music_offtopic"]'},
|
||||
)
|
||||
if response.status == 200 and (
|
||||
results := list(
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .common import LimitedSizeDict, filter_secrets, format_duration, surround
|
||||
from .common import LimitedSizeDict, filter_secrets, format_duration
|
||||
from .discord import (
|
||||
ChannelResponseWrapper,
|
||||
MessageInteractionWrapper,
|
||||
@ -24,5 +24,4 @@ __all__ = [
|
||||
"MessageInteractionWrapper",
|
||||
"reply",
|
||||
"snowflake_timestamp",
|
||||
"surround",
|
||||
]
|
||||
|
@ -3,10 +3,6 @@ from collections import OrderedDict
|
||||
from constants import SECRETS
|
||||
|
||||
|
||||
def surround(inner, outer="```"):
|
||||
return outer + str(inner) + outer
|
||||
|
||||
|
||||
def format_duration(duration: int, natural: bool = False, short: bool = False):
|
||||
def format_plural(noun, count):
|
||||
if short:
|
||||
|
Loading…
x
Reference in New Issue
Block a user