Add support of disabled extension for poll
This commit is contained in:
parent
deffba71e7
commit
9ad618900a
1 changed files with 6 additions and 2 deletions
|
@ -6,8 +6,9 @@ from discord import Embed, RawReactionActionEvent, RawMessageDeleteEvent, RawBul
|
||||||
from discord.ext.commands import BadArgument
|
from discord.ext.commands import BadArgument
|
||||||
|
|
||||||
import db
|
import db
|
||||||
|
from administrator.check import is_enabled
|
||||||
from administrator.logger import logger
|
from administrator.logger import logger
|
||||||
|
from administrator.utils import event_is_enabled
|
||||||
|
|
||||||
extension_name = "poll"
|
extension_name = "poll"
|
||||||
logger = logger.getChild(extension_name)
|
logger = logger.getChild(extension_name)
|
||||||
|
@ -25,6 +26,7 @@ class Poll(commands.Cog):
|
||||||
return "Create poll with a simple command"
|
return "Create poll with a simple command"
|
||||||
|
|
||||||
@commands.group("poll", pass_context=True)
|
@commands.group("poll", pass_context=True)
|
||||||
|
@is_enabled()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def poll(self, ctx: commands.Context, name: str, *choices):
|
async def poll(self, ctx: commands.Context, name: str, *choices):
|
||||||
if name == "help":
|
if name == "help":
|
||||||
|
@ -67,9 +69,11 @@ class Poll(commands.Cog):
|
||||||
user = await self.bot.fetch_user(payload.user_id)
|
user = await self.bot.fetch_user(payload.user_id)
|
||||||
else:
|
else:
|
||||||
user = payload.member
|
user = payload.member
|
||||||
|
|
||||||
if not user.bot:
|
if not user.bot:
|
||||||
s = db.Session()
|
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()
|
p = s.query(db.Polls).filter(db.Polls.message == payload.message_id).first()
|
||||||
if p:
|
if p:
|
||||||
message = await self.bot.get_channel(p.channel).fetch_message(p.message)
|
message = await self.bot.get_channel(p.channel).fetch_message(p.message)
|
||||||
|
|
Reference in a new issue