Discord.py试图制作黑名单系统

时间:2020-07-14 16:17:35

标签: python discord.py blacklist

我试图在discord.py中创建黑名单系统

class blackk(commands.CheckFailure): pass

def __global_check_once(ctx):
    cursor.execute(f"SELECT ban_id FROM bany WHERE ban_id = {ctx.author.id}")
    r = cursor.fetchone()
    if r is not None:
        raise blackk()
    else:
        return 


@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, blackk):
        await ctx.send("blacklisted")

我真的很需要。有人知道更好的方法(请举例)

1 个答案:

答案 0 :(得分:0)

我相信__global_check_once已被bot_check_once取代。它应该返回TrueFalseYou can find a list of Cog special methods here