diff options
-rw-r--r-- | bot.py | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -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 |