Compare commits

..

11 Commits

10 changed files with 90 additions and 87 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
/.direnv .direnv
/.env .env
/.venv .mypy_cache
/result* .venv
__pycache__ __pycache__
result*
+8 -8
View File
@@ -4,7 +4,7 @@ import disnake
import disnake_paginator import disnake_paginator
from ... import arguments, audio, commands, utils from ... import arguments, audio, commands, utils
from ...constants import EMBED_COLOR from ...constants import EMBED_COLOR, USER_QUEUE_MAX
from ...state import client, players, trusted_users from ...state import client, players, trusted_users
from .playback import resume from .playback import resume
from .utils import command_allowed, ensure_joined, play_next from .utils import command_allowed, ensure_joined, play_next
@@ -142,13 +142,13 @@ async def queue_or_play(message, edited=False):
), ),
), ),
) )
>= 5 >= USER_QUEUE_MAX
and not len(message.guild.voice_client.channel.members) == 2 and not len(message.guild.voice_client.channel.members) == 2
and message.author.id not in trusted_users and message.author.id not in trusted_users
): ):
await utils.reply( await utils.reply(
message, message,
"you can only queue **5 items** without the manage channels permission!", f"you can only queue **{USER_QUEUE_MAX} items** without the manage channels permission!",
) )
return return
@@ -203,21 +203,21 @@ async def queue_or_play(message, edited=False):
natural=True, natural=True,
) )
def embed(description): def create_embed(description):
e = disnake.Embed( embed = disnake.Embed(
description=description, description=description,
color=EMBED_COLOR, color=EMBED_COLOR,
) )
if formatted_duration and len(players[message.guild.id].queue) > 1: if formatted_duration and len(players[message.guild.id].queue) > 1:
e.set_footer(text=f"{formatted_duration} in total") embed.set_footer(text=f"{formatted_duration} in total")
return e return embed
await disnake_paginator.ButtonPaginator( await disnake_paginator.ButtonPaginator(
invalid_user_function=utils.invalid_user_handler, invalid_user_function=utils.invalid_user_handler,
color=EMBED_COLOR, color=EMBED_COLOR,
segments=list( segments=list(
map( map(
embed, create_embed,
[ [
"\n\n".join( "\n\n".join(
[ [
+63 -64
View File
@@ -1,28 +1,52 @@
import os import os
YTDL_OPTIONS = { APPLICATION_FLAGS = {
"color": "never", 1 << 12: "Presence Intent",
"default_search": "auto", 1 << 13: "Presence Intent (unverified)",
"format": "bestaudio/best", 1 << 14: "Guild Members Intent",
"ignoreerrors": False, 1 << 15: "Guild Members Intent (unverified)",
"logtostderr": False, 1 << 16: "Unusual Growth (verification suspended)",
"no_warnings": True, 1 << 18: "Message Content Intent",
"noplaylist": True, 1 << 19: "Message Content Intent (unverified)",
"outtmpl": "%(extractor)s-%(id)s-%(title)s.%(ext)s", 1 << 23: "Suports Application Commands",
"quiet": True, }
"restrictfilenames": True, BADGE_EMOJIS = {
"socket_timeout": 15, "Discord Employee": "<:DiscordStaff:879666899980546068>",
"source_address": "0.0.0.0", "Discord Partner": "<:DiscordPartner:879668340434534400>",
"HypeSquad Events": "<:HypeSquadEvents:879666970310606848>",
"Bug Hunter Level 1": "<:BugHunter1:879666851448234014>",
"HypeSquad Bravery": "<:HypeSquadBravery:879666945153175612>",
"HypeSquad Brilliance": "<:HypeSquadBrilliance:879666956884643861>",
"HypeSquad Balance": "<:HypeSquadBalance:879666934717771786>",
"Early Supporter": "<:EarlySupporter:879666916493496400>",
"Team User": "<:TeamUser:890866907996127305>",
"Bug Hunter Level 2": "<:BugHunter2:879666866971357224>",
"Verified Bot": "<:VerifiedBot:879670687554498591>",
"Verified Bot Developer": "<:VerifiedBotDeveloper:879669786550890507>",
"Discord Certified Moderator": "<:DiscordModerator:879666882976837654>",
"HTTP Interactions Only": "<:HTTPInteractionsOnly:1047141867806015559>",
"Active Developer": "<:ActiveDeveloper:1047141451244523592>",
} }
BAR_LENGTH = 35 BAR_LENGTH = 35
EMBED_COLOR = 0xFF6600 EMBED_COLOR = 0x00B6FF
OWNERS = [531392146767347712] OWNERS = [531392146767347712]
PREFIX = "%" PREFIX = "%"
SPONSORBLOCK_CATEGORY_NAMES = { PUBLIC_FLAGS = {
"music_offtopic": "non-music", 1 << 0: "Discord Employee",
"selfpromo": "self promotion", 1 << 1: "Discord Partner",
"sponsor": "sponsored", 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",
} }
REACTIONS = { REACTIONS = {
"cat": ["🐈"], "cat": ["🐈"],
@@ -62,51 +86,26 @@ RELOADABLE_MODULES = [
"yt_dlp", "yt_dlp",
"yt_dlp.version", "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",
}
BADGE_EMOJIS = {
"Discord Employee": "<:DiscordStaff:879666899980546068>",
"Discord Partner": "<:DiscordPartner:879668340434534400>",
"HypeSquad Events": "<:HypeSquadEvents:879666970310606848>",
"Bug Hunter Level 1": "<:BugHunter1:879666851448234014>",
"HypeSquad Bravery": "<:HypeSquadBravery:879666945153175612>",
"HypeSquad Brilliance": "<:HypeSquadBrilliance:879666956884643861>",
"HypeSquad Balance": "<:HypeSquadBalance:879666934717771786>",
"Early Supporter": "<:EarlySupporter:879666916493496400>",
"Team User": "<:TeamUser:890866907996127305>",
"Bug Hunter Level 2": "<:BugHunter2:879666866971357224>",
"Verified Bot": "<:VerifiedBot:879670687554498591>",
"Verified Bot Developer": "<:VerifiedBotDeveloper:879669786550890507>",
"Discord Certified Moderator": "<:DiscordModerator:879666882976837654>",
"HTTP Interactions Only": "<:HTTPInteractionsOnly:1047141867806015559>",
"Active Developer": "<:ActiveDeveloper:1047141451244523592>",
}
APPLICATION_FLAGS = {
1 << 12: "Presence Intent",
1 << 13: "Presence Intent (unverified)",
1 << 14: "Guild Members Intent",
1 << 15: "Guild Members Intent (unverified)",
1 << 16: "Unusual Growth (verification suspended)",
1 << 18: "Message Content Intent",
1 << 19: "Message Content Intent (unverified)",
1 << 23: "Suports Application Commands",
}
SECRETS = { SECRETS = {
"TOKEN": os.getenv("BOT_TOKEN"), "TOKEN": os.getenv("BOT_TOKEN"),
} }
SPONSORBLOCK_CATEGORY_NAMES = {
"music_offtopic": "non-music",
"selfpromo": "self promotion",
"sponsor": "sponsored",
}
USER_QUEUE_MAX = 5
YTDL_OPTIONS = {
"color": "never",
"default_search": "auto",
"format": "bestaudio/best",
"ignoreerrors": False,
"logtostderr": False,
"no_warnings": True,
"noplaylist": True,
"outtmpl": "%(extractor)s-%(id)s-%(title)s.%(ext)s",
"quiet": True,
"restrictfilenames": True,
"socket_timeout": 15,
"source_address": "0.0.0.0",
}
+4 -1
View File
@@ -50,7 +50,10 @@ async def transcript(
except Exception: except Exception:
pass pass
if (message.guild.voice_client.source.id != initial_id) or kill["transcript"]: if (
message.guild.voice_client.source
and (message.guild.voice_client.source.id != initial_id)
) or kill["transcript"]:
kill["transcript"] = False kill["transcript"] = False
break break
+1 -1
View File
@@ -1,6 +1,6 @@
import unittest import unittest
import utils from errornocord import utils
class TestFilterSecrets(unittest.TestCase): class TestFilterSecrets(unittest.TestCase):
+1 -2
View File
@@ -1,7 +1,6 @@
import unittest import unittest
import audio from errornocord import audio, utils
import utils
class TestFormatDuration(unittest.TestCase): class TestFormatDuration(unittest.TestCase):
+1 -1
View File
@@ -3,7 +3,7 @@ from collections import OrderedDict
from ..constants import SECRETS from ..constants import SECRETS
def surround(inner: str, outer="```") -> str: def surround(inner: str | int, outer="```") -> str:
return outer + str(inner) + outer return outer + str(inner) + outer
+3 -2
View File
@@ -1,15 +1,16 @@
import ctypes import ctypes.util
import time import time
from logging import debug, error from logging import debug, error
import disnake import disnake
from .. import commands
from ..constants import OWNERS from ..constants import OWNERS
from ..state import command_cooldowns, message_responses from ..state import command_cooldowns, message_responses
def cooldown(message, cooldown_time: int): def cooldown(message, cooldown_time: int):
from .. import commands
if message.author.id in OWNERS: if message.author.id in OWNERS:
return return
+2 -2
View File
@@ -18,13 +18,13 @@
{ {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
name = "errornocord"; name = "errornocord";
buildInputs = [ self'.packages.default ];
inputsFrom = [ self'.packages.default ]; inputsFrom = [ self'.packages.default ];
buildInputs = [ self'.packages.default ];
}; };
packages = rec { packages = rec {
errornocord = pkgs.callPackage ./nix/package.nix { inherit self; };
default = errornocord; default = errornocord;
errornocord = pkgs.callPackage ./nix/package.nix { inherit self; };
}; };
}; };
+2 -2
View File
@@ -44,9 +44,9 @@ let
}; };
}; };
in in
python3Packages.buildPythonPackage { python3Packages.buildPythonPackage rec {
pname = "dave.py"; pname = "dave.py";
version = self.pins."dave.py".revision; version = src.revision;
pyproject = true; pyproject = true;
src = self.pins."dave.py"; src = self.pins."dave.py";