Compare commits
8 Commits
fbdd442a8e
...
b71331a102
Author | SHA1 | Date | |
---|---|---|---|
b71331a102 | |||
d63155d0fb | |||
40cd8238dd | |||
81e30c7e70 | |||
a1d63f1bb1 | |||
1a24754549 | |||
2c6d05b33d | |||
117438be76 |
@ -34,7 +34,7 @@ class ArgumentParser:
|
|||||||
await utils.reply(message, f"`{e}`")
|
await utils.reply(message, f"`{e}`")
|
||||||
|
|
||||||
|
|
||||||
def range_type(string, min=0, max=100):
|
def range_type(string: str, min=0, max=100):
|
||||||
try:
|
try:
|
||||||
value = int(string)
|
value = int(string)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -32,6 +32,8 @@ class Command(Enum):
|
|||||||
def match_token(token: str) -> list[Command]:
|
def match_token(token: str) -> list[Command]:
|
||||||
if token.lower() == "r":
|
if token.lower() == "r":
|
||||||
return [Command.RELOAD]
|
return [Command.RELOAD]
|
||||||
|
elif token.lower() == "s":
|
||||||
|
return [Command.SKIP]
|
||||||
|
|
||||||
if exact_match := list(
|
if exact_match := list(
|
||||||
filter(
|
filter(
|
||||||
|
@ -171,7 +171,10 @@ async def queue_or_play(message, edited=False):
|
|||||||
else:
|
else:
|
||||||
players[message.guild.id].queue_add(queued)
|
players[message.guild.id].queue_add(queued)
|
||||||
|
|
||||||
if not message.guild.voice_client.source:
|
if not message.guild.voice_client:
|
||||||
|
await utils.reply(message, "unexpected disconnect from voice channel!")
|
||||||
|
return
|
||||||
|
elif not message.guild.voice_client.source:
|
||||||
play_next(message, first=True)
|
play_next(message, first=True)
|
||||||
elif args.now:
|
elif args.now:
|
||||||
message.guild.voice_client.stop()
|
message.guild.voice_client.stop()
|
||||||
|
26
events.py
26
events.py
@ -1,14 +1,12 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
import time
|
from logging import debug, info, warning
|
||||||
from logging import info
|
|
||||||
|
|
||||||
import fun
|
|
||||||
|
|
||||||
import commands
|
import commands
|
||||||
import core
|
import core
|
||||||
|
import fun
|
||||||
import tasks
|
import tasks
|
||||||
from state import client, start_time
|
from state import client
|
||||||
|
|
||||||
|
|
||||||
def prepare():
|
def prepare():
|
||||||
@ -42,19 +40,29 @@ async def on_message_edit(before, after):
|
|||||||
await core.on_message(after, edited=True)
|
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):
|
async def on_voice_state_update(member, before, after):
|
||||||
await core.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 event_type, handlers in client.get_listeners().items():
|
||||||
for handler in handlers:
|
for handler in handlers:
|
||||||
client.remove_listener(handler, event_type)
|
client.remove_listener(handler, event_type)
|
||||||
|
|
||||||
client.add_listener(on_bulk_message_delete, "on_bulk_message_delete")
|
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, "on_message")
|
||||||
client.add_listener(on_message_delete, "on_message_delete")
|
client.add_listener(on_message_delete, "on_message_delete")
|
||||||
client.add_listener(on_message_edit, "on_message_edit")
|
client.add_listener(on_message_edit, "on_message_edit")
|
||||||
|
2
extra.py
2
extra.py
@ -81,7 +81,7 @@ def messages_per_second(limit=500):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def auto_count(channel_id):
|
async def auto_count(channel_id: int):
|
||||||
if (channel := await client.fetch_channel(channel_id)) and isinstance(
|
if (channel := await client.fetch_channel(channel_id)) and isinstance(
|
||||||
channel, disnake.TextChannel
|
channel, disnake.TextChannel
|
||||||
):
|
):
|
||||||
|
7
fun.py
7
fun.py
@ -4,6 +4,7 @@ import commands
|
|||||||
|
|
||||||
|
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
if "gn" in commands.tokenize(message.content, remove_prefix=False):
|
if random.random() < 0.01 and "gn" in commands.tokenize(
|
||||||
if random.random() < 0.01:
|
message.content, remove_prefix=False
|
||||||
await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"]))
|
):
|
||||||
|
await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"]))
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
aiohttp
|
||||||
audioop-lts
|
audioop-lts
|
||||||
disnake
|
disnake
|
||||||
disnake_paginator
|
disnake_paginator
|
||||||
|
@ -10,11 +10,11 @@ CATEGORY_NAMES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def get_segments(videoId: str):
|
async def get_segments(video_id: str):
|
||||||
if videoId in sponsorblock_cache:
|
if video_id in sponsorblock_cache:
|
||||||
return sponsorblock_cache[videoId]
|
return sponsorblock_cache[video_id]
|
||||||
|
|
||||||
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
|
hashPrefix = hashlib.sha256(video_id.encode()).hexdigest()[:4]
|
||||||
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}",
|
||||||
@ -22,8 +22,8 @@ async def get_segments(videoId: str):
|
|||||||
)
|
)
|
||||||
if response.status == 200 and (
|
if response.status == 200 and (
|
||||||
results := list(
|
results := list(
|
||||||
filter(lambda v: videoId == v["videoID"], await response.json())
|
filter(lambda v: video_id == v["videoID"], await response.json())
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
sponsorblock_cache[videoId] = results[0]
|
sponsorblock_cache[video_id] = results[0]
|
||||||
return results[0]
|
return results[0]
|
||||||
|
@ -88,6 +88,8 @@ class YTDLSource(PCMVolumeTransformer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "entries" in data:
|
if "entries" in data:
|
||||||
|
if not data["entries"]:
|
||||||
|
raise Exception("no entries provided by yt-dlp!")
|
||||||
data = data["entries"][0]
|
data = data["entries"][0]
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
@ -158,7 +160,12 @@ class QueuedSong:
|
|||||||
name="Uploader",
|
name="Uploader",
|
||||||
value=self.player.uploader,
|
value=self.player.uploader,
|
||||||
)
|
)
|
||||||
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.like_count
|
||||||
|
else "Unknown",
|
||||||
|
)
|
||||||
embed.add_field(name="Views", value=f"{self.player.view_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="Published", value=f"<t:{self.player.timestamp}>")
|
||||||
embed.add_field(name="Volume", value=f"{int(self.player.volume * 100)}%")
|
embed.add_field(name="Volume", value=f"{int(self.player.volume * 100)}%")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user