From 1e5cb5ead712e6f1c2ed4829b2316de03c5d826a Mon Sep 17 00:00:00 2001 From: astehr Date: Sun, 22 Oct 2023 00:02:57 +0400 Subject: [PATCH] guild_ids refactor --- .idea/misc.xml | 2 +- aicord/__main__.py | 11 ++++++----- aicord/core/ai/summarize.py | 2 -- aicord/discord/bot.py | 5 ++++- aicord/discord/cogs/__init__.py | 2 +- aicord/discord/cogs/summarize.py | 8 +++++++- aicord/discord/utils.py | 1 + 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index cc49e94..f6fdbf3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/aicord/__main__.py b/aicord/__main__.py index a89231e..e6cf390 100644 --- a/aicord/__main__.py +++ b/aicord/__main__.py @@ -1,14 +1,15 @@ -from __future__ import annotations - import asyncio + from dotenv import load_dotenv -load_dotenv() +from aicord.discord.bot import main + if __name__ == "__main__": - from aicord.discord.bot import main + load_dotenv() try: asyncio.run(main()) + except KeyboardInterrupt: - pass \ No newline at end of file + pass diff --git a/aicord/core/ai/summarize.py b/aicord/core/ai/summarize.py index f2cd436..659249c 100644 --- a/aicord/core/ai/summarize.py +++ b/aicord/core/ai/summarize.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import logging import os diff --git a/aicord/discord/bot.py b/aicord/discord/bot.py index 6ff3a6f..e0f3a98 100644 --- a/aicord/discord/bot.py +++ b/aicord/discord/bot.py @@ -8,10 +8,12 @@ from aicord.discord.cogs import COGS + class BotConfig(TypedDict, total=False): owner_ids: list[int] owner_guild_ids: list[int] + class AicordBot(discord.Bot): def __init__(self, config: BotConfig) -> None: intents = discord.Intents.default() @@ -41,4 +43,5 @@ async def main() -> None: for cog in COGS: bot.load_extension(cog.name) - await bot.start() \ No newline at end of file + await bot.start() + print("Bot started.") diff --git a/aicord/discord/cogs/__init__.py b/aicord/discord/cogs/__init__.py index e2b2407..b25bf0d 100644 --- a/aicord/discord/cogs/__init__.py +++ b/aicord/discord/cogs/__init__.py @@ -10,4 +10,4 @@ ] ) -COGS = _cogs \ No newline at end of file +COGS = _cogs diff --git a/aicord/discord/cogs/summarize.py b/aicord/discord/cogs/summarize.py index 7968058..ba3298b 100644 --- a/aicord/discord/cogs/summarize.py +++ b/aicord/discord/cogs/summarize.py @@ -14,8 +14,14 @@ class Summarize(commands.Cog): def __init__(self, bot_: discord.Bot): self.bot = bot_ + if not os.environ.get('GUILD_IDS'): + guild_ids = None + else: + guild_ids = os.environ.get('GUILD_IDS') - summarize = SlashCommandGroup("summarize", description="Get a quick summary of what's going on in the server.", guild_ids=[994570645671268442,966090258104062023]) + summarize = SlashCommandGroup("summarize", + description="Get a quick summary of what's going on in the server.", + guild_ids=guild_ids) @staticmethod async def load_chat(channel: discord.TextChannel, interval: str) -> list[discord.Message]: diff --git a/aicord/discord/utils.py b/aicord/discord/utils.py index 015cceb..697e8ec 100644 --- a/aicord/discord/utils.py +++ b/aicord/discord/utils.py @@ -2,6 +2,7 @@ import discord + def collect_participants(messages: list[discord.Message]) -> dict[int, str]: participants = {} for message in messages: