1
Fork 0
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:
wlinator 2024-09-01 08:02:55 -04:00
parent d100cd792c
commit 104aab3681
3 changed files with 13 additions and 8 deletions

View file

@ -53,6 +53,10 @@ class ErrorHandler(commands.Cog):
self._old_tree_error = tree.on_error self._old_tree_error = tree.on_error
tree.on_error = self.on_app_command_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( async def on_app_command_error(
self, self,
interaction: discord.Interaction, interaction: discord.Interaction,

View file

@ -1,19 +1,19 @@
from discord.ext import commands import discord
from discord import app_commands
from lib.exceptions import BirthdaysDisabled from lib.exceptions import BirthdaysDisabled
from services.config_service import GuildConfig from services.config_service import GuildConfig
def birthdays_enabled(): def birthdays_enabled():
async def predicate(ctx: commands.Context[commands.Bot]) -> bool: async def predicate(interaction: discord.Interaction) -> bool:
if ctx.guild is None: if interaction.guild is None:
return True return True
guild_config = GuildConfig(ctx.guild.id) guild_config = GuildConfig(interaction.guild.id)
if guild_config.birthday_channel_id is None:
if not guild_config.birthday_channel_id:
raise BirthdaysDisabled raise BirthdaysDisabled
return True return True
return commands.check(predicate) return app_commands.check(predicate)

View file

@ -1,9 +1,10 @@
from discord import app_commands
from discord.ext import commands from discord.ext import commands
from lib.const import CONST 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. Raised when the birthdays module is disabled in ctx.guild.
""" """