Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda