From 4c114aef6e9284f7e27dd76d61f5332d5348efd6 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 5 Nov 2020 14:42:16 +0100 Subject: [PATCH] Add support of disabled extension for greetings --- extensions/greetings.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/greetings.py b/extensions/greetings.py index 1c3b0ce..bd169a1 100644 --- a/extensions/greetings.py +++ b/extensions/greetings.py @@ -2,8 +2,10 @@ from discord.ext import commands from discord import Member, Embed, Forbidden from discord.ext.commands import BadArgument +from administrator.check import is_enabled from administrator.logger import logger from administrator import db, config +from administrator.utils import event_is_enabled def check_greetings_message_type(message_type): @@ -23,6 +25,7 @@ class Greetings(commands.Cog): return "Setup join and leave message" @commands.group("greetings", pass_context=True) + @is_enabled() @commands.guild_only() @commands.has_permissions(manage_guild=True) async def greetings(self, ctx: commands.Context): @@ -84,6 +87,8 @@ class Greetings(commands.Cog): @commands.Cog.listener() async def on_member_join(self, member: Member): s = db.Session() + if not event_is_enabled(self.qualified_name, member.guild.id, s): + return m = s.query(db.Greetings).filter(db.Greetings.guild == member.guild.id).first() s.close() if m and m.join_enable: @@ -96,6 +101,8 @@ class Greetings(commands.Cog): @commands.Cog.listener() async def on_member_remove(self, member: Member): s = db.Session() + if not event_is_enabled(self.qualified_name, member.guild.id, s): + return m = s.query(db.Greetings).filter(db.Greetings.guild == member.guild.id).first() s.close() if m and m.leave_enable: