From fdbe11b673f6e139a4555dbd897b622375eb2d6d Mon Sep 17 00:00:00 2001 From: Skillet Date: Wed, 2 Aug 2023 23:07:44 -0400 Subject: [PATCH] add updaterole command --- autowl/Cogs/Group.py | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/autowl/Cogs/Group.py b/autowl/Cogs/Group.py index 8810c6e..57f3d07 100644 --- a/autowl/Cogs/Group.py +++ b/autowl/Cogs/Group.py @@ -18,19 +18,7 @@ class Group(commands.Cog, name="group"): def __init__(self, client: Bot): self.client = client - async def baseperm(self, interaction: discord.Interaction, role: discord.Role, perms: str): - - await interaction.response.send_message("Whitelist group successfully added/updated") - if role.id in self.client.whitelistGrps.keys(): - if perms is not None: - self.client.whitelistGrps[role.id].squadPerms = perms - self.client.whitelistGrps[role.id].updateGroup() - else: - log.info(f"Adding {role.name} ({role.id}) as a Whitelist role") - self.client.whitelistGrps[role.id] = config.WhitelistGroup( - name=role.name, roleID=role.id, permissions=perms - ) - + async def updateRole(self, role:discord.Role): self.client.squadjs.connect() membsup = [] for memb in role.members: @@ -49,6 +37,34 @@ class Group(commands.Cog, name="group"): self.client.squadjs.commit() self.client.squadjs.close() + + async def baseperm(self, interaction: discord.Interaction, role: discord.Role, perms: str): + + await interaction.response.send_message("Whitelist group successfully added/updated") + if role.id in self.client.whitelistGrps.keys(): + if perms is not None: + self.client.whitelistGrps[role.id].squadPerms = perms + self.client.whitelistGrps[role.id].updateGroup() + else: + log.info(f"Adding {role.name} ({role.id}) as a Whitelist role") + self.client.whitelistGrps[role.id] = config.WhitelistGroup( + name=role.name, roleID=role.id, permissions=perms + ) + + await self.updateRole(role) + + @app_commands.command() + async def update( + self, + interaction: discord.Interaction, + role: discord.Role + ): + if role.id in self.client.whitelistGrps.keys(): + await interaction.response.send_message("updating role!") + await self.updateRole(role) + else: + await interaction.response.send_message("role not found!") + @app_commands.command() async def add( self,