From ff5993997ab0cc68f698afbb45eaed9d3ec3fd8f Mon Sep 17 00:00:00 2001 From: Lukas Nedbalek Date: Tue, 24 Sep 2024 16:08:30 +0200 Subject: [PATCH] rf: file structure, default config file --- main.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 83b97a9..0e68a89 100644 --- a/main.py +++ b/main.py @@ -2,8 +2,18 @@ import discord from discord.ext import commands from configparser import ConfigParser -# Bot token (replace with your own) -TOKEN = 'MTE1NDc0ODQ3MzE4MzMwNTc4OQ.Gz_Q7u.02sb2YNV_QQy7Bs19roXlB62mjoMKA6y8aubHU' +TOKEN = 'MTE1NDc0ODQ3MzE4MzMwNTc4OQ.Gz_Q7u.02sb2YNV_QQy7Bs19roXlB62mjoMKA6y8aubHU' # Bot token (replace with your own) +DEFAULT_CONFIG_FILE = 'config.ini' # Configuration file with server IDs and study group roles + + +# Create an instance of the bot +intents = discord.Intents.default() +intents.members = True + +config = ConfigParser() +config.read(DEFAULT_CONFIG_FILE) + +bot = commands.Bot(command_prefix='!', intents=intents) async def reply_error(ctx: commands.Context, message: str): @@ -16,22 +26,16 @@ async def reply(ctx: commands.Context, message: str): def get_server_IDs(): config = ConfigParser() - config.read("config.ini") + config.read(DEFAULT_CONFIG_FILE) server_IDs = [] for section in config.sections(): server_IDs.append(int(config[section]['server_ID'])) return server_IDs - -# Create an instance of the bot -intents = discord.Intents.default() -intents.members = True -bot = commands.Bot(command_prefix='!', intents=intents) - # Study group roles and their corresponding IDs (you can customize this) def get_study_groups(server_id): config = ConfigParser() - config.read("config.ini") + config.read(DEFAULT_CONFIG_FILE) study_groups = {} for section in config.sections():