This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import asyncio, functools, inspect | |
from typing import Awaitable, Callable, TypeVar, cast | |
R = TypeVar("R") | |
F = TypeVar("F", bound=Callable[..., object]) | |
ExceptionTypes = type[Exception] | tuple[type[Exception], ...] | |
PropagateTypes = type[BaseException] | tuple[type[BaseException], ...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import argparse | |
import json | |
from enum import Enum, auto | |
from dataclasses import dataclass, asdict | |
from itertools import starmap | |
from copy import deepcopy | |
from typing import ( | |
List, Tuple, Dict, Union, Optional, Iterable, Callable, | |
TypeVar, Generic, NamedTuple, cast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import itertools | |
from typing import Iterator, Iterable, Callable, Union, List, Tuple | |
Predicate = Callable[[os.DirEntry], bool] | |
Sorter = Callable[[Iterable[os.DirEntry]], List[os.DirEntry]] | |
# predicates | |
no_ext = lambda e: '.' not in e.name | |
not_hidden = lambda e: not e.name.startswith('.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
import aiofiles | |
import io | |
import array | |
import base64 | |
from discord.ext import commands | |
from pydub import AudioSegment | |
from typing import Union, Any, Optional, Tuple | |
class VoiceMessage(discord.Message): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define a helper function that performs an action on a cog or all cogs | |
async def _cog_action(self, ctx: commands.Context, action: Literal["load", "unload", "reload"], cog: Optional[str] = None) -> None: | |
""" | |
Perform an action on a cog or all cogs. | |
Parameters: | |
ctx (commands.Context): The Discord command context. | |
action (Literal["load", "unload", "reload"]): The action to perform (load, unload, or reload). | |
cog (Optional[str]): The specific cog name to perform the action on. If None, the action will be applied to all cogs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BooleanTransformer(app_commands.Transformer): | |
@property | |
def choices(self) -> List[app_commands.Choice]: | |
return [app_commands.Choice(name="True", value="True"), app_commands.Choice(name="False", value="False")] | |
async def transform(self, interaction: discord.Interaction, value: str) -> bool: | |
return {"True": True, "False": False}[value] | |
@app_commands.command(name="test", description='Test bool') | |
@app_commands.describe(option="Bool test") |