Compare commits

..

13 Commits

11 changed files with 90 additions and 87 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
.direnv
.env
.mypy_cache
.venv
__pycache__
result
result*
+9 -9
View File
@@ -4,7 +4,7 @@ import disnake
import disnake_paginator
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 .playback import resume
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 message.author.id not in trusted_users
):
await utils.reply(
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
@@ -203,21 +203,21 @@ async def queue_or_play(message, edited=False):
natural=True,
)
def embed(description):
e = disnake.Embed(
def create_embed(description):
embed = disnake.Embed(
description=description,
color=EMBED_COLOR,
)
if formatted_duration and len(players[message.guild.id].queue) > 1:
e.set_footer(text=f"{formatted_duration} in total")
return e
embed.set_footer(text=f"{formatted_duration} in total")
return embed
await disnake_paginator.ButtonPaginator(
invalid_user_function=utils.invalid_user_handler,
color=EMBED_COLOR,
segments=list(
map(
embed,
create_embed,
[
"\n\n".join(
[
@@ -255,7 +255,7 @@ async def skip(message):
if not command_allowed(message):
return
if players[message.guild.id] and not players[message.guild.id].queue:
if message.guild.id in players and not players[message.guild.id].queue:
del players[message.guild.id]
message.guild.voice_client.stop()
await utils.reply(
+63 -64
View File
@@ -1,28 +1,52 @@
import os
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",
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",
}
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>",
}
BAR_LENGTH = 35
EMBED_COLOR = 0xFF6600
EMBED_COLOR = 0x00B6FF
OWNERS = [531392146767347712]
PREFIX = "%"
SPONSORBLOCK_CATEGORY_NAMES = {
"music_offtopic": "non-music",
"selfpromo": "self promotion",
"sponsor": "sponsored",
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",
}
REACTIONS = {
"cat": ["🐈"],
@@ -62,51 +86,26 @@ RELOADABLE_MODULES = [
"yt_dlp",
"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 = {
"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:
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
break
+1 -1
View File
@@ -1,6 +1,6 @@
import unittest
import utils
from errornocord import utils
class TestFilterSecrets(unittest.TestCase):
+1 -2
View File
@@ -1,7 +1,6 @@
import unittest
import audio
import utils
from errornocord import audio, utils
class TestFormatDuration(unittest.TestCase):
+1 -1
View File
@@ -3,7 +3,7 @@ from collections import OrderedDict
from ..constants import SECRETS
def surround(inner: str, outer="```") -> str:
def surround(inner: str | int, outer="```") -> str:
return outer + str(inner) + outer
+3 -2
View File
@@ -1,15 +1,16 @@
import ctypes
import ctypes.util
import time
from logging import debug, error
import disnake
from .. import commands
from ..constants import OWNERS
from ..state import command_cooldowns, message_responses
def cooldown(message, cooldown_time: int):
from .. import commands
if message.author.id in OWNERS:
return
+2 -2
View File
@@ -18,13 +18,13 @@
{
devShells.default = pkgs.mkShell {
name = "errornocord";
buildInputs = [ self'.packages.default ];
inputsFrom = [ self'.packages.default ];
buildInputs = [ self'.packages.default ];
};
packages = rec {
errornocord = pkgs.callPackage ./nix/package.nix { inherit self; };
default = errornocord;
errornocord = pkgs.callPackage ./nix/package.nix { inherit self; };
};
};
+2 -2
View File
@@ -44,9 +44,9 @@ let
};
};
in
python3Packages.buildPythonPackage {
python3Packages.buildPythonPackage rec {
pname = "dave.py";
version = self.pins."dave.py".revision;
version = src.revision;
pyproject = true;
src = self.pins."dave.py";
+2 -2
View File
@@ -27,10 +27,10 @@ let
disnake_paginator = python3Packages.buildPythonPackage {
pname = "disnake-paginator";
version = "1.0.8";
pyproject = true;
src = self.pins.disnake-paginator;
pyproject = true;
build-system = [ python3Packages.setuptools ];
propagatedBuildInputs = [
@@ -43,10 +43,10 @@ in
python3Packages.buildPythonApplication {
pname = "errornocord";
version = "0.1.0";
pyproject = true;
src = lib.cleanSource ../.;
pyproject = true;
build-system = [ python3Packages.setuptools ];
propagatedBuildInputs = with python3Packages; [