#Commands.check doesn't trigger commands.CheckFailure

1 messages · Page 1 of 1 (latest)

polar orchid
#

I have Following Issue i created a checks system

     @bot.event
    async def on_application_command_error(ctx: discord.ApplicationContext, error):
        if isinstance(error, commands.MissingRole):
            await ctx.respond("Du hast nicht die erforderliche Rolle, um diesen Befehl auszuführen!")
            return
        elif isinstance(error, commands.CommandOnCooldown):
            return
        elif isinstance(error, commands.NoPrivateMessage):
            message = await ctx.respond("This Command works only on Server.", ephemeral=True, delete_after = 10)
            return
        elif isinstance(error, commands.CommandError):
            message = await ctx.respond("Der Befehl konnte nicht verarbeitet werden, Bitte versuche es später erneut.", ephemeral=True, delete_after = 10)
            log.error(f"Ein Fehler ist aufgetreten: {error}", exc_info=True)
            return
        elif isinstance(error, commands.CheckFailure):
            return
        else:
            log.error(f"Ein Fehler ist aufgetreten: {error}", exc_info=True)
            em = discord.Embed(color = discord.Color.red(), description = f"Es ist ein Fehler aufgetreten bitte versuch es später erneut.")
            await ctx.respond(embed = em, delete_after = 10)
            return

def is_in_channel():
    return commands.check(check_channel)

# Benutzerdefinierte Überprüfungsfunktion, die sicherstellt, dass der Befehl im gewünschten Channel ausgeführt wird
async def check_channel(ctx):
    if await db.mainChannel(guild=ctx.guild) is not None:
        channel = discord.utils.get(ctx.guild.channels, name=await db.mainChannel(guild=ctx.guild))
        if ctx.channel.name != f"{channel}" and channel is not None:
            await ctx.respond(f"Dieser Befehl darf nur im <#{channel.id}> Channel verwendet werden.", ephemeral=True)
            return False
    return True
#

The System works fine if it is True but if i have return False,
i got not a commands.CheckFailure what was expected
it triggers the else.... and i don't know why

i have also tryt a raise commands.CheckFailure but then i get a commands.CommandError error

the command has following

      
    # Leaderboard Command
    @commands.slash_command(guild_only=True)
    @commands.guild_only()
    @checks.is_in_channel()
    async def leaderboard(self, ctx: discord.ApplicationContext):
        """
        Get rank list from Server
        """