Compare commits
No commits in common. "10f7ce991c9193e172d4180eaa60f625795803c6" and "8ef4c85bd8f145b391231a93cb9a26c32c819e72" have entirely different histories.
10f7ce991c
...
8ef4c85bd8
@ -120,9 +120,9 @@ async def lookup(message):
|
||||
except Exception:
|
||||
raise Exception(f"unable to find badge: {PUBLIC_FLAGS[flag]}")
|
||||
|
||||
user_object = await client.fetch_user(user.id)
|
||||
accent_color = 0x000000
|
||||
if user_object.accent_color is not None:
|
||||
user_object = await client.fetch_user(user.id)
|
||||
if user_object.accent_color is None:
|
||||
accent_color = user_object.accent_color
|
||||
|
||||
embed = disnake.Embed(color=accent_color)
|
||||
|
@ -55,17 +55,14 @@ def match(command: str) -> list[Command] | None:
|
||||
|
||||
|
||||
@lru_cache
|
||||
def tokenize(string: str, remove_prefix: bool = True) -> list[str]:
|
||||
def tokenize(string: str) -> list[str]:
|
||||
tokens = []
|
||||
token = ""
|
||||
in_quotes = False
|
||||
quote_char = None
|
||||
escape = False
|
||||
|
||||
if remove_prefix:
|
||||
string = string[len(constants.PREFIX) :]
|
||||
|
||||
for char in string:
|
||||
for char in string[len(constants.PREFIX) :]:
|
||||
if escape:
|
||||
token += char
|
||||
escape = False
|
||||
|
@ -178,7 +178,7 @@ async def queue_or_play(message, edited=False):
|
||||
else:
|
||||
await utils.reply(
|
||||
message,
|
||||
f"**{1 if args.next else len(players[message.guild.id].queue)}.** {queued.format()}",
|
||||
f"**{len(players[message.guild.id].queue)}.** {queued.format()}",
|
||||
)
|
||||
|
||||
utils.cooldown(message, 2)
|
||||
|
4
fun.py
4
fun.py
@ -1,9 +1,7 @@
|
||||
import random
|
||||
|
||||
import commands
|
||||
|
||||
|
||||
async def on_message(message):
|
||||
if "gn" in commands.tokenize(message.content, remove_prefix=False):
|
||||
if "gn" in message.content:
|
||||
if random.random() < 0.01:
|
||||
await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"]))
|
||||
|
@ -12,8 +12,7 @@ async def get_segments(videoId: str):
|
||||
hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4]
|
||||
session = aiohttp.ClientSession()
|
||||
response = await session.get(
|
||||
f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}",
|
||||
params={"categories": '["sponsor", "music_offtopic"]'},
|
||||
f'https://sponsor.ajay.app/api/skipSegments/{hashPrefix}?categories=["music_offtopic"]'
|
||||
)
|
||||
if response.status == 200 and (
|
||||
results := list(
|
||||
|
@ -27,21 +27,13 @@ async def reply(message, *args, **kwargs):
|
||||
kwargs["content"] = None
|
||||
elif len(kwargs) == 0:
|
||||
kwargs["embeds"] = []
|
||||
|
||||
try:
|
||||
await message_responses[message.id].edit(
|
||||
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
else:
|
||||
response = await message.reply(
|
||||
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
|
||||
)
|
||||
except Exception:
|
||||
response = await channel_send(message, *args, **kwargs)
|
||||
message_responses[message.id] = response
|
||||
return message_responses[message.id]
|
||||
|
||||
|
27
youtubedl.py
27
youtubedl.py
@ -1,5 +1,4 @@
|
||||
import asyncio
|
||||
import audioop
|
||||
import collections
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Optional
|
||||
@ -12,30 +11,6 @@ from constants import BAR_LENGTH, EMBED_COLOR, YTDL_OPTIONS
|
||||
ytdl = yt_dlp.YoutubeDL(YTDL_OPTIONS)
|
||||
|
||||
|
||||
class PCMVolumeTransformer(disnake.AudioSource):
|
||||
def __init__(self, original: disnake.AudioSource, volume: float = 1.0) -> None:
|
||||
if original.is_opus():
|
||||
raise disnake.ClientException("AudioSource must not be Opus encoded.")
|
||||
|
||||
self.original = original
|
||||
self.volume = volume
|
||||
|
||||
@property
|
||||
def volume(self) -> float:
|
||||
return self._volume
|
||||
|
||||
@volume.setter
|
||||
def volume(self, value: float) -> None:
|
||||
self._volume = max(value, 0.0)
|
||||
|
||||
def cleanup(self) -> None:
|
||||
self.original.cleanup()
|
||||
|
||||
def read(self) -> bytes:
|
||||
ret = self.original.read()
|
||||
return audioop.mul(ret, 2, self._volume)
|
||||
|
||||
|
||||
class CustomAudioSource(disnake.AudioSource):
|
||||
def __init__(self, source):
|
||||
self._source = source
|
||||
@ -56,7 +31,7 @@ class CustomAudioSource(disnake.AudioSource):
|
||||
return self.read_count * 0.02
|
||||
|
||||
|
||||
class YTDLSource(PCMVolumeTransformer):
|
||||
class YTDLSource(disnake.PCMVolumeTransformer):
|
||||
def __init__(
|
||||
self, source: CustomAudioSource, *, data: dict[str, Any], volume: float = 0.5
|
||||
):
|
||||
|
Loading…
x
Reference in New Issue
Block a user