2024-03-25 20:18:33 +00:00
|
|
|
from discord.ext import commands
|
2024-03-29 17:17:51 +00:00
|
|
|
|
2024-06-15 22:45:24 +00:00
|
|
|
from lib.exceptions import LumiExceptions
|
2024-06-20 10:34:03 +00:00
|
|
|
from services.config_service import GuildConfig
|
2023-06-19 14:20:17 +00:00
|
|
|
|
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
def birthdays_enabled():
|
|
|
|
async def predicate(ctx):
|
|
|
|
if ctx.guild is None:
|
|
|
|
return True
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
guild_config = GuildConfig(ctx.guild.id)
|
2024-03-04 10:25:00 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
if not guild_config.birthday_channel_id:
|
2024-06-15 22:45:24 +00:00
|
|
|
raise LumiExceptions.BirthdaysDisabled
|
2024-03-04 10:25:00 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
return True
|
2024-03-04 10:25:00 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
return commands.check(predicate)
|
2024-03-19 07:40:01 +00:00
|
|
|
|
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
def allowed_in_channel():
|
|
|
|
async def predicate(ctx):
|
|
|
|
if ctx.guild is None:
|
|
|
|
return True
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
guild_config = GuildConfig(ctx.guild.id)
|
|
|
|
command_channel_id = guild_config.command_channel_id
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
if command_channel_id:
|
2024-07-08 17:22:17 +00:00
|
|
|
command_channel = await ctx.bot.get_or_fetch_channel(
|
2024-07-17 11:47:26 +00:00
|
|
|
ctx.guild,
|
|
|
|
command_channel_id,
|
2024-07-08 17:22:17 +00:00
|
|
|
)
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
if ctx.channel.id != command_channel_id and command_channel:
|
2024-06-15 22:45:24 +00:00
|
|
|
raise LumiExceptions.NotAllowedInChannel(command_channel)
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
return True
|
2023-06-19 14:20:17 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
return commands.check(predicate)
|