rf: file structure, default config file
This commit is contained in:
parent
6d4f0d7e8d
commit
ff5993997a
1 changed files with 14 additions and 10 deletions
24
main.py
24
main.py
|
@ -2,8 +2,18 @@ import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
|
||||||
# Bot token (replace with your own)
|
TOKEN = 'MTE1NDc0ODQ3MzE4MzMwNTc4OQ.Gz_Q7u.02sb2YNV_QQy7Bs19roXlB62mjoMKA6y8aubHU' # Bot token (replace with your own)
|
||||||
TOKEN = 'MTE1NDc0ODQ3MzE4MzMwNTc4OQ.Gz_Q7u.02sb2YNV_QQy7Bs19roXlB62mjoMKA6y8aubHU'
|
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):
|
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():
|
def get_server_IDs():
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read("config.ini")
|
config.read(DEFAULT_CONFIG_FILE)
|
||||||
server_IDs = []
|
server_IDs = []
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
server_IDs.append(int(config[section]['server_ID']))
|
server_IDs.append(int(config[section]['server_ID']))
|
||||||
return server_IDs
|
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)
|
# Study group roles and their corresponding IDs (you can customize this)
|
||||||
def get_study_groups(server_id):
|
def get_study_groups(server_id):
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read("config.ini")
|
config.read(DEFAULT_CONFIG_FILE)
|
||||||
|
|
||||||
study_groups = {}
|
study_groups = {}
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
|
|
Loading…
Reference in a new issue