mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-03 04:23:14 +00:00
38 lines
1,000 B
Python
38 lines
1,000 B
Python
from discord.ext import commands
|
|
|
|
from lib.exceptions import RacuExceptions
|
|
from services.GuildConfig import GuildConfig
|
|
|
|
|
|
def birthdays_enabled():
|
|
async def predicate(ctx):
|
|
if ctx.guild is None:
|
|
return True
|
|
|
|
guild_config = GuildConfig(ctx.guild.id)
|
|
|
|
if not guild_config.birthday_channel_id:
|
|
raise RacuExceptions.BirthdaysDisabled
|
|
|
|
return True
|
|
|
|
return commands.check(predicate)
|
|
|
|
|
|
def allowed_in_channel():
|
|
async def predicate(ctx):
|
|
if ctx.guild is None:
|
|
return True
|
|
|
|
guild_config = GuildConfig(ctx.guild.id)
|
|
command_channel_id = guild_config.command_channel_id
|
|
|
|
if command_channel_id:
|
|
command_channel = await ctx.bot.get_or_fetch_channel(ctx.guild, command_channel_id)
|
|
|
|
if ctx.channel.id != command_channel_id and command_channel:
|
|
raise RacuExceptions.NotAllowedInChannel(command_channel)
|
|
|
|
return True
|
|
|
|
return commands.check(predicate)
|