Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!