From 8b36f6c0b2dea24a3563fc4afe02d49db4a2385f Mon Sep 17 00:00:00 2001 From: trueold89 Date: Mon, 3 Jun 2024 16:53:40 +0300 Subject: [PATCH] Init bot.py - Add create bot command --- hellmbot/bot.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 hellmbot/bot.py diff --git a/hellmbot/bot.py b/hellmbot/bot.py new file mode 100644 index 0000000..014c3cf --- /dev/null +++ b/hellmbot/bot.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +from hellmbot.env import ENV +from hellmbot.db import ServersDB +from discord import Intents +from discord.ext import commands + + +############### +# Bot's logic # +############### + +def init_bot() -> commands.Bot: + intents = Intents.default() + intents.message_content = True + return commands.Bot(command_prefix="/", intents=intents) + + +bot = init_bot() + + +def start() -> None: + bot.run(ENV.BOT_TOKEN.fget(None)) + + +@bot.command() +async def create(ctx: commands.Context) -> None: + server = ctx.guild + db = ServersDB(server.id) + circles_count = ENV.CIRCLES_COUNT.fget(None) + group = await server.create_category(f"{circles_count} Circles of Hell") + if db: + db.clear_channels() + for circle in range(circles_count): + vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group) + db.add_channel(vc.id, circle + 1) + + +if __name__ == "__main__": + start()