Changed project structure by adding cogs for birthday feature related actions
This commit is contained in:
13
modules/setup/bot.py
Normal file
13
modules/setup/bot.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import discord
|
||||
from ..cogs.birthday import BirthdayCog
|
||||
|
||||
bot_intents = discord.Intents.default()
|
||||
bot_intents.message_content = True
|
||||
bot_intents.members = True
|
||||
bot_intents.presences = True
|
||||
bot_intents.guilds = True
|
||||
bot_intents.reactions = True
|
||||
|
||||
bot = discord.Bot(command_prefix='$', intents=bot_intents)
|
||||
|
||||
bot.add_cog(BirthdayCog(bot))
|
||||
15
modules/setup/data.py
Normal file
15
modules/setup/data.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import os, json
|
||||
|
||||
DATA_DIR = 'data/'
|
||||
|
||||
def get_guild_data(guild_id:int):
|
||||
"""Reads and returns the dictionary of guild data from the guild's JSON data file."""
|
||||
path = os.path.join(DATA_DIR, f'{guild_id}.json')
|
||||
with open(path, 'r') as f:
|
||||
return json.load(f)
|
||||
|
||||
def save_guild_data(guild_id:int, data):
|
||||
"""Saves the dictionary of guild data to the guild's JSON data file."""
|
||||
path = os.path.join(DATA_DIR, f'{guild_id}.json')
|
||||
with open(path, 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
8
modules/setup/logger.py
Normal file
8
modules/setup/logger.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(asctime)s: %(name)s: %(message)s')
|
||||
LOGGER = logging.getLogger('botmafieux')
|
||||
LOGGER.setLevel(logging.DEBUG)
|
||||
handler = logging.FileHandler(filename='botmafieux.log', encoding='utf-8', mode='w')
|
||||
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
|
||||
LOGGER.addHandler(handler)
|
||||
Reference in New Issue
Block a user