1
0
Fork 0

Add support of disabled extension for presentation

This commit is contained in:
Ethanell 2020-11-05 14:53:06 +01:00
parent 9ad618900a
commit 2ba73ea5d0

View file

@ -2,9 +2,10 @@ from discord.ext import commands
from discord import Embed, Message from discord import Embed, Message
from discord.ext.commands import BadArgument from discord.ext.commands import BadArgument
from administrator.check import is_enabled
from administrator.logger import logger from administrator.logger import logger
from administrator import db from administrator import db
from administrator.utils import event_is_enabled
extension_name = "presentation" extension_name = "presentation"
logger = logger.getChild(extension_name) logger = logger.getChild(extension_name)
@ -18,6 +19,7 @@ class Presentation(commands.Cog):
return "Give role to user who make a presentation in a dedicated channel" return "Give role to user who make a presentation in a dedicated channel"
@commands.group("presentation", pass_context=True) @commands.group("presentation", pass_context=True)
@is_enabled()
@commands.guild_only() @commands.guild_only()
@commands.has_permissions(manage_guild=True) @commands.has_permissions(manage_guild=True)
async def presentation(self, ctx: commands.Context): async def presentation(self, ctx: commands.Context):
@ -63,6 +65,8 @@ class Presentation(commands.Cog):
async def on_message(self, message: Message): async def on_message(self, message: Message):
if message.guild is not None: if message.guild is not None:
s = db.Session() s = db.Session()
if not event_is_enabled(self.qualified_name, message.guild.id, s):
return
p = s.query(db.Presentation).filter(db.Presentation.guild == message.guild.id).first() p = s.query(db.Presentation).filter(db.Presentation.guild == message.guild.id).first()
s.close() s.close()
if p and p.channel == message.channel.id and p.role not in map(lambda x: x.id, message.author.roles): if p and p.channel == message.channel.id and p.role not in map(lambda x: x.id, message.author.roles):