Compare commits

..

No commits in common. "b71331a102a3ab48490d0dec337bcd89de1b43b2" and "fbdd442a8e19ad4b724993ead7fa7a9c579376e8" have entirely different histories.

9 changed files with 22 additions and 44 deletions

View File

@ -34,7 +34,7 @@ class ArgumentParser:
await utils.reply(message, f"`{e}`")
def range_type(string: str, min=0, max=100):
def range_type(string, min=0, max=100):
try:
value = int(string)
except ValueError:

View File

@ -32,8 +32,6 @@ class Command(Enum):
def match_token(token: str) -> list[Command]:
if token.lower() == "r":
return [Command.RELOAD]
elif token.lower() == "s":
return [Command.SKIP]
if exact_match := list(
filter(

View File

@ -171,10 +171,7 @@ async def queue_or_play(message, edited=False):
else:
players[message.guild.id].queue_add(queued)
if not message.guild.voice_client:
await utils.reply(message, "unexpected disconnect from voice channel!")
return
elif not message.guild.voice_client.source:
if not message.guild.voice_client.source:
play_next(message, first=True)
elif args.now:
message.guild.voice_client.stop()

View File

@ -1,12 +1,14 @@
import asyncio
import threading
from logging import debug, info, warning
import time
from logging import info
import fun
import commands
import core
import fun
import tasks
from state import client
from state import client, start_time
def prepare():
@ -40,29 +42,19 @@ async def on_message_edit(before, after):
await core.on_message(after, edited=True)
async def on_ready():
info(f"logged in as {client.user} in {round(time.time() - start_time, 1)}s")
async def on_voice_state_update(member, before, after):
await core.on_voice_state_update(member, before, after)
async def on_ready():
info(f"logged in as {client.user}")
async def on_connect():
debug("connected to the gateway!")
async def on_disconnect():
warning("disconnected from the gateway!")
for event_type, handlers in client.get_listeners().items():
for handler in handlers:
client.remove_listener(handler, event_type)
client.add_listener(on_bulk_message_delete, "on_bulk_message_delete")
client.add_listener(on_connect, "on_connect")
client.add_listener(on_disconnect, "on_disconnect")
client.add_listener(on_message, "on_message")
client.add_listener(on_message_delete, "on_message_delete")
client.add_listener(on_message_edit, "on_message_edit")

View File

@ -81,7 +81,7 @@ def messages_per_second(limit=500):
)
async def auto_count(channel_id: int):
async def auto_count(channel_id):
if (channel := await client.fetch_channel(channel_id)) and isinstance(
channel, disnake.TextChannel
):

5
fun.py
View File

@ -4,7 +4,6 @@ import commands
async def on_message(message):
if random.random() < 0.01 and "gn" in commands.tokenize(
message.content, remove_prefix=False
):
if "gn" in commands.tokenize(message.content, remove_prefix=False):
if random.random() < 0.01:
await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"]))

View File

@ -1,4 +1,3 @@
aiohttp
audioop-lts
disnake
disnake_paginator

View File

@ -10,11 +10,11 @@ CATEGORY_NAMES = {
}
async def get_segments(video_id: str):
if video_id in sponsorblock_cache:
return sponsorblock_cache[video_id]
async def get_segments(videoId: str):
if videoId in sponsorblock_cache:
return sponsorblock_cache[videoId]
hashPrefix = hashlib.sha256(video_id.encode()).hexdigest()[:4]
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
session = aiohttp.ClientSession()
response = await session.get(
f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}",
@ -22,8 +22,8 @@ async def get_segments(video_id: str):
)
if response.status == 200 and (
results := list(
filter(lambda v: video_id == v["videoID"], await response.json())
filter(lambda v: videoId == v["videoID"], await response.json())
)
):
sponsorblock_cache[video_id] = results[0]
sponsorblock_cache[videoId] = results[0]
return results[0]

View File

@ -88,8 +88,6 @@ class YTDLSource(PCMVolumeTransformer):
)
if "entries" in data:
if not data["entries"]:
raise Exception("no entries provided by yt-dlp!")
data = data["entries"][0]
return cls(
@ -160,12 +158,7 @@ class QueuedSong:
name="Uploader",
value=self.player.uploader,
)
embed.add_field(
name="Likes",
value=f"{self.player.like_count:,}"
if self.player.like_count
else "Unknown",
)
embed.add_field(name="Likes", value=f"{self.player.like_count:,}")
embed.add_field(name="Views", value=f"{self.player.view_count:,}")
embed.add_field(name="Published", value=f"<t:{self.player.timestamp}>")
embed.add_field(name="Volume", value=f"{int(self.player.volume * 100)}%")