From 1d0efc3c85b171d7df733512cbaaaeb94a34acee Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 22 Feb 2023 22:34:03 -0600 Subject: [PATCH] feat: add list command This allows users to see which roles are whitelisted on Squad --- autowl/Cogs/Group.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/autowl/Cogs/Group.py b/autowl/Cogs/Group.py index 1ebf545..560e92a 100644 --- a/autowl/Cogs/Group.py +++ b/autowl/Cogs/Group.py @@ -1,4 +1,5 @@ import discord +import random import logging from autowl import config from autowl.bot import Bot @@ -50,3 +51,32 @@ class Group(commands.Cog, name="group"): f"Removed **{role.name}** from Whitelisted roles" ) self.client.whitelist.pop(role.name) + + @app_commands.command() + async def list_whitelisted_roles(self, interaction: discord.Interaction): + whitelisted_roles = [] + if not interaction.guild: + await interaction.response.send_message( + "This command must be ran within a discord server" + ) + return + + for group in self.client.whitelist: + role_id = self.client.whitelist[group].discord_role_id + if not interaction.guild.get_role(role_id): + continue + whitelisted_roles.append(f"<@&{role_id}>") + + embed_description = ( + "\n".join(whitelisted_roles) + if whitelisted_roles + else "No whitelisted roles found, you can some using `/add`" + ) + + embed = discord.Embed( + title="Whitelisted Roles", + description=embed_description, + color=random.randint(0, 0xFFFFFF), + ).set_footer(text="Users with these roles will be whitelisted on Squad") + + await interaction.response.send_message(embed=embed)