Rename main.py to app.py, add init and main dunder files.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Empty init file for off_cooldown_bot module."""
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Starts the app for agon."""
|
||||
|
||||
import logging
|
||||
|
||||
from .app import run
|
||||
|
||||
nextcord_logger = logging.getLogger("nextcord")
|
||||
nextcord_logger.setLevel(logging.DEBUG)
|
||||
nextcord_handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w")
|
||||
nextcord_handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
||||
nextcord_logger.addHandler(nextcord_handler)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
@@ -1,23 +1,15 @@
|
||||
"""Main file for Agon bot."""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from utilities import config
|
||||
from utilities.logger import agon_logger
|
||||
|
||||
nextcord_logger = logging.getLogger("nextcord")
|
||||
nextcord_logger.setLevel(logging.DEBUG)
|
||||
nextcord_handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w")
|
||||
nextcord_handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
||||
nextcord_logger.addHandler(nextcord_handler)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
def run() -> None:
|
||||
"""Main function for bot."""
|
||||
min_python_version = (3, 12)
|
||||
if sys.version_info < min_python_version:
|
||||
@@ -34,8 +26,8 @@ def main() -> None:
|
||||
)
|
||||
|
||||
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
|
||||
for folder in os.listdir("cogs"):
|
||||
bot.load_extension(f"cogs.{folder}")
|
||||
for folder in pathlib.Path("./agon/cogs").iterdir():
|
||||
bot.load_extension(f"agon.cogs.{folder.name}")
|
||||
|
||||
@bot.listen()
|
||||
async def on_ready() -> None:
|
||||
@@ -47,7 +39,3 @@ def main() -> None:
|
||||
|
||||
# Run Discord bot
|
||||
bot.run(config.DISCORD_TOKEN)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -3,17 +3,17 @@
|
||||
import re
|
||||
|
||||
import nextcord
|
||||
from cogs.submission.verification_view import VerificationView
|
||||
from database.db import engine
|
||||
from database.models import Category, CategoryGroup, Guild, Submission
|
||||
from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlmodel import col
|
||||
|
||||
from cogs.submission.verification_view import VerificationView
|
||||
from database.db import engine
|
||||
from database.models import Category, CategoryGroup, Guild, Submission
|
||||
from main import agon_logger
|
||||
from utilities.utils import autofill_categories, autofill_groups, submit_score
|
||||
|
||||
from agon.app import agon_logger
|
||||
|
||||
|
||||
class SubmissionCog(commands.Cog):
|
||||
"""Class holds command for submitting a score."""
|
||||
|
||||
@@ -4,13 +4,13 @@ import time
|
||||
|
||||
import nextcord
|
||||
import pandas as pd
|
||||
from database.db import engine
|
||||
from database.models import Category, CategoryGroup, Guild, Score
|
||||
from sqlalchemy import distinct, select
|
||||
from sqlalchemy.orm import Session, aliased
|
||||
from sqlmodel import col
|
||||
|
||||
from database.db import engine
|
||||
from database.models import Category, CategoryGroup, Guild, Score
|
||||
from main import agon_logger
|
||||
from agon.app import agon_logger
|
||||
|
||||
MAX_LINE_LENGTH = 142
|
||||
|
||||
|
||||
Reference in New Issue
Block a user