Add ability to delete groups
This commit is contained in:
22
bot.py
22
bot.py
@@ -415,6 +415,28 @@ async def group_command(ctx: commands.Context, subcommand: Optional[str], arg: O
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
await ctx.send("Can't find that group!")
|
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':
|
elif subcommand == 'create':
|
||||||
if arg is None:
|
if arg is None:
|
||||||
await ctx.send("Group name required!")
|
await ctx.send("Group name required!")
|
||||||
|
|||||||
Reference in New Issue
Block a user