2024-03-25 20:18:33 +00:00
|
|
|
from discord.ext import commands
|
2024-03-29 17:17:51 +00:00
|
|
|
|
2024-03-25 20:18:33 +00:00
|
|
|
from lib.exceptions import RacuExceptions
|
2024-03-08 11:16:42 +00:00
|
|
|
from services.GuildConfig 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:
|
|
|
|
raise RacuExceptions.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:
|
|
|
|
command_channel = await ctx.bot.get_or_fetch_channel(ctx.guild, command_channel_id)
|
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:
|
|
|
|
raise RacuExceptions.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)
|