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