Skip to content

Commit

Permalink
Fix staff checks for slash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Jan 17, 2025
1 parent 0034afc commit 88963bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions kurisu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from subprocess import check_output, CalledProcessError
from typing import Optional
from utils import WarnsManager, ConfigurationManager, RestrictionsManager, ExtrasManager, FiltersManager, UserLogManager
from utils.checks import InsufficientStaffRank
from utils.checks import InsufficientStaffRank, AppInsufficientStaffRank
from utils.help import KuriHelp, HelpView, CategorySelect, MainHelpPaginator
from utils.utils import create_error_embed
from utils.context import KurisuContext
Expand Down Expand Up @@ -439,7 +439,7 @@ async def on_error(
elif isinstance(error, app_commands.MissingPermissions):
await ctx.send(f"{author.mention} You don't have permission to use `{command}`.", ephemeral=True)

elif isinstance(error, InsufficientStaffRank):
elif isinstance(error, AppInsufficientStaffRank):
await ctx.send(str(error), ephemeral=True)

elif isinstance(error, app_commands.CheckFailure):
Expand Down
9 changes: 7 additions & 2 deletions utils/checks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import discord

from discord import app_commands
from discord.app_commands import AppCommandError
from discord.ext import commands
from utils.configuration import StaffRank
from typing import TYPE_CHECKING
Expand All @@ -9,7 +10,11 @@
from kurisu import Kurisu


class InsufficientStaffRank(commands.CheckFailure):
class InsufficientStaffRank(commands.CheckFailure, AppCommandError):
message: str


class AppInsufficientStaffRank(app_commands.CheckFailure):
message: str


Expand All @@ -25,7 +30,7 @@ def is_staff_app(role: str):
async def predicate(interaction: discord.Interaction) -> bool:
if (interaction.guild and interaction.user == interaction.guild.owner) or check_staff(interaction.client, role, interaction.user.id):
return True
raise InsufficientStaffRank(f"You must be at least {role} to use this command.")
raise AppInsufficientStaffRank(f"You must be at least {role} to use this command.")
return app_commands.check(predicate)


Expand Down

0 comments on commit 88963bf

Please sign in to comment.