1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Administrator-py/administrator/check.py

20 lines
487 B
Python
Raw Normal View History

from discord.ext import commands
import db
class ExtensionDisabled(commands.CheckFailure):
pass
def is_enabled():
async def check(ctx: commands.Context):
if ctx.command.cog and ctx.guild:
s = db.Session()
es = s.query(db.ExtensionState).get((ctx.command.cog.qualified_name, ctx.guild.id))
s.close()
if es and not es.state:
raise ExtensionDisabled()
return True
return commands.check(check)