Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

332
Visualizações
Checks don't work correctly on my library

Summary:

I own my own Discord.py library called "Fusion.py", and I somehow broke commands.check, I don't know how and I tried several things to try and fix it, but nothing worked. Here's the library's Github Page. Here's the GitHub link to the exact function.

Furthermore, I have uninstalled my library and installed enhanced-dpy library just to see if that worked and this check function is copied from edpy, therefore if it worked for them it should work for me, but after installing their library it works on their library, but doesn't work on mine... I've asked a lot of people, and no-one could help me... T-T

Code:

def check(predicate: Check, **command_attrs: Any) -> Callable[[T], T]:
    def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]:
        if isinstance(func, Command):
            func.checks.append(predicate)
            func._update_attrs(**command_attrs)
        else:
            if not hasattr(func, "__commands_checks__"):
                func.__commands_checks__ = []
            if not hasattr(func, "__command_attrs__"):
                func.__command_attrs__ = {}

            func.__commands_checks__.append(predicate)
            func.__command_attrs__.update(command_attrs)

        return func

    if inspect.iscoroutinefunction(predicate):
        decorator.predicate = predicate
    else:

        @functools.wraps(predicate)
        async def wrapper(ctx):
            return predicate(ctx)  # type: ignore

        decorator.predicate = wrapper

    return decorator  # type: ignore

Usage Code:

from discord.ext import commands
from cool_utils import Terminal


Const = {
    "TESTERS": []
}

def is_tester():
    Terminal.display("Testing tester")
    async def predicate(ctx):
        try:
            if ctx.message.author.id in Const.get("TESTERS"):
                Terminal.display("TESTER_DEBUG: User is tester")
                return True

            else:
                Terminal.display("TESTER_DEBBUG: User is not tester")
                return False
        except Exception as error:
            Terminal.error(error)
            return False

    try:
        return commands.check(predicate)
    except Exception as error:
        Terminal.error(error)


bot = commands.Bot("!")

@bot.event
async def on_ready():
    print("Test")

@bot.command()
@is_tester()
async def test(ctx):
    await ctx.send("Test")

bot.run("TOKEN")
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda