From 06c724a65c31271a609ea194fdab8f6b02ea8791 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Fri, 12 Mar 2021 14:39:37 +0100 Subject: [PATCH] Add ability to delete groups --- bot.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bot.py b/bot.py index 5065cba..209bc73 100644 --- a/bot.py +++ b/bot.py @@ -415,6 +415,28 @@ async def group_command(ctx: commands.Context, subcommand: Optional[str], arg: O else: await ctx.send("Can't find that group!") + elif subcommand == 'delete': + if arg is None: + await ctx.send("Group name required!") + return + + groups = collect_group_channels(groups_cat) + archive_cat = find_category(guild, config_get("groups-archive-category", guild.id)) + if archive_cat is None: + await fail_category("archive", config_get("groups-archive-category", guild.id)) + return + + active_groups = collect_group_channels(groups_cat) + archive_groups = collect_group_channels(archive_cat) + + role = guild.get_role(config_get("groups-role-prefix", guild.id)) + if role is not None: + await role.delete(reason="Delete group " + arg) + + if arg in active_groups: + await active_groups[arg].delete(reason="Delete group " + arg) + if arg in archive_groups: + await archive_groups[arg].delete(reason="Delete group " + arg) elif subcommand == 'create': if arg is None: await ctx.send("Group name required!")