Add ability to delete groups

This commit is contained in:
2021-03-12 14:39:37 +01:00
parent 6a5a38c759
commit 06c724a65c

22
bot.py
View File

@@ -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!")