From 9ad618900a9f606a9d39192461506bdb7a942447 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 5 Nov 2020 14:52:03 +0100 Subject: [PATCH] Add support of disabled extension for poll --- extensions/poll.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/poll.py b/extensions/poll.py index d247a9e..e39d617 100644 --- a/extensions/poll.py +++ b/extensions/poll.py @@ -6,8 +6,9 @@ from discord import Embed, RawReactionActionEvent, RawMessageDeleteEvent, RawBul from discord.ext.commands import BadArgument import db +from administrator.check import is_enabled from administrator.logger import logger - +from administrator.utils import event_is_enabled extension_name = "poll" logger = logger.getChild(extension_name) @@ -25,6 +26,7 @@ class Poll(commands.Cog): return "Create poll with a simple command" @commands.group("poll", pass_context=True) + @is_enabled() @commands.guild_only() async def poll(self, ctx: commands.Context, name: str, *choices): if name == "help": @@ -67,9 +69,11 @@ class Poll(commands.Cog): user = await self.bot.fetch_user(payload.user_id) else: user = payload.member - + if not user.bot: s = db.Session() + if payload.guild_id and not event_is_enabled(self.qualified_name, payload.guild_id, s): + return p = s.query(db.Polls).filter(db.Polls.message == payload.message_id).first() if p: message = await self.bot.get_channel(p.channel).fetch_message(p.message)