summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatrixAeria <upezu@student.kit.edu>2020-09-28 03:46:54 +0200
committerNatrixAeria <upezu@student.kit.edu>2020-09-28 03:46:54 +0200
commit1cd9424573863320ad0a4e611e248e1bad1e60b6 (patch)
tree786f3f341e862f40f10fdb7e0246e03ee274c44c
parent146496c146dd489023c19323027288508c4abb9d (diff)
Add destroy command
-rw-r--r--bot.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/bot.py b/bot.py
index 779ef1e..f97f218 100644
--- a/bot.py
+++ b/bot.py
@@ -1,3 +1,4 @@
+import asyncio
import discord
import config
from command_utils import command, CommandClient
@@ -34,22 +35,42 @@ class Client(CommandClient):
await ctx.answer(f'info: voice channel created "{lobby}" ({lobby.id})')
return lobby
+ def get_meta_channel(self, ctx):
+ return (self.meta_channel
+ or discord.utils.get(ctx.guild.categories,
+ name=config.CATEGORY_CHANNEL_NAME))
+
+ def get_lobby_channel(self, ctx):
+ return (self.lobby_channel
+ or discord.utils.get(ctx.guild.voice_channels,
+ name=config.LOBBY_CHANNEL_NAME,
+ category=self.meta_channel))
+
@command(
names = ('init', 'create', 'inti', 'craete', 'cretae', 'c', 'i', '+'),
description = 'create a new lobby'
)
async def init(self, ctx):
self.meta_channel = (
- self.meta_channel
- or discord.utils.get(ctx.guild.categories, name=config.CATEGORY_CHANNEL_NAME)
+ self.get_meta_channel(ctx)
or await self.create_category(ctx)
)
self.lobby_channel = (
- self.lobby_channel
- or discord.utils.get(ctx.guild.voice_channels, name=config.LOBBY_CHANNEL_NAME, category=self.meta_channel)
+ self.get_lobby_channel(ctx)
or await self.create_lobby(ctx)
)
+ @command(
+ names = ('destroy', 'kill', 'desctruction', 'genocide', '-'),
+ description = f'destruct all {config.NAME} channels'
+ )
+ async def destroy(self, ctx):
+ futures = []
+ for channel in (self.get_meta_channel(ctx), self.get_lobby_channel(ctx)):
+ if channel:
+ futures.append(channel.delete())
+ await asyncio.wait(futures)
+
if __name__ == '__main__':
from os import getenv