From 847d5c8c89894a1019cdb136d0adffa7380a053f Mon Sep 17 00:00:00 2001 From: Vegard Berg Date: Thu, 4 Aug 2022 04:15:28 +0200 Subject: [PATCH] Check mark reactions in welcome channel approve user. A check mark reaction emoji can be used to approve a user, if it is done in the Join/Leave message channel. It requires the one reacting to have the "Manage Roles" permission. --- commands/gatekeep.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/commands/gatekeep.py b/commands/gatekeep.py index bb5ce66..296ca73 100644 --- a/commands/gatekeep.py +++ b/commands/gatekeep.py @@ -207,6 +207,30 @@ class Gatekeep(Extension): str(gk.gatekeep_approve_message).format(member=user, guild=ctx.guild) ) + @listen(events.MessageReactionAdd) + async def on_reaction_add(self, reaction: events.MessageReactionAdd): + if not reaction.emoji.name in [ + "✅", + "☑", + "✔", + ] or not reaction.author.has_permission(Permissions.MANAGE_ROLES): + return + + gk: GatekeepModel + gk, _ = GatekeepModel.get_or_create(guild_id=reaction.guild.id) + jl: JoinLeaveModel + jl, _ = JoinLeaveModel.get_or_create(guild_id=reaction.guild.id) + + if reaction.message.channel.id != jl.message_channel: + return + + await reaction.message.author.add_role(int(gk.gatekeep_approve_role)) + await reaction.message.channel.send( + str(gk.gatekeep_approve_message).format( + member=reaction.message.author, guild=reaction.guild + ) + ) + @slash_command( name="captcha", description="Complete a captcha",