mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 18:23:12 +00:00
feat: Fix birthday check handling
This commit is contained in:
parent
d100cd792c
commit
104aab3681
3 changed files with 13 additions and 8 deletions
|
@ -53,6 +53,10 @@ class ErrorHandler(commands.Cog):
|
|||
self._old_tree_error = tree.on_error
|
||||
tree.on_error = self.on_app_command_error
|
||||
|
||||
async def cog_unload(self):
|
||||
tree = self.bot.tree
|
||||
tree.on_error = self._old_tree_error
|
||||
|
||||
async def on_app_command_error(
|
||||
self,
|
||||
interaction: discord.Interaction,
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
from discord.ext import commands
|
||||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
from lib.exceptions import BirthdaysDisabled
|
||||
from services.config_service import GuildConfig
|
||||
|
||||
|
||||
def birthdays_enabled():
|
||||
async def predicate(ctx: commands.Context[commands.Bot]) -> bool:
|
||||
if ctx.guild is None:
|
||||
async def predicate(interaction: discord.Interaction) -> bool:
|
||||
if interaction.guild is None:
|
||||
return True
|
||||
|
||||
guild_config = GuildConfig(ctx.guild.id)
|
||||
|
||||
if not guild_config.birthday_channel_id:
|
||||
guild_config = GuildConfig(interaction.guild.id)
|
||||
if guild_config.birthday_channel_id is None:
|
||||
raise BirthdaysDisabled
|
||||
|
||||
return True
|
||||
|
||||
return commands.check(predicate)
|
||||
return app_commands.check(predicate)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
from lib.const import CONST
|
||||
|
||||
|
||||
class BirthdaysDisabled(commands.CheckFailure):
|
||||
class BirthdaysDisabled(commands.CheckFailure, app_commands.CheckFailure):
|
||||
"""
|
||||
Raised when the birthdays module is disabled in ctx.guild.
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue