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."""
|
"""Main file for Agon bot."""
|
||||||
|
|
||||||
import logging
|
import pathlib
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from utilities import config
|
from utilities import config
|
||||||
from utilities.logger import agon_logger
|
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 run() -> None:
|
||||||
def main() -> None:
|
|
||||||
"""Main function for bot."""
|
"""Main function for bot."""
|
||||||
min_python_version = (3, 12)
|
min_python_version = (3, 12)
|
||||||
if sys.version_info < min_python_version:
|
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>
|
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
|
||||||
for folder in os.listdir("cogs"):
|
for folder in pathlib.Path("./agon/cogs").iterdir():
|
||||||
bot.load_extension(f"cogs.{folder}")
|
bot.load_extension(f"agon.cogs.{folder.name}")
|
||||||
|
|
||||||
@bot.listen()
|
@bot.listen()
|
||||||
async def on_ready() -> None:
|
async def on_ready() -> None:
|
||||||
@@ -47,7 +39,3 @@ def main() -> None:
|
|||||||
|
|
||||||
# Run Discord bot
|
# Run Discord bot
|
||||||
bot.run(config.DISCORD_TOKEN)
|
bot.run(config.DISCORD_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import nextcord
|
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 nextcord.ext import commands
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlmodel import col
|
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 utilities.utils import autofill_categories, autofill_groups, submit_score
|
||||||
|
|
||||||
|
from agon.app import agon_logger
|
||||||
|
|
||||||
|
|
||||||
class SubmissionCog(commands.Cog):
|
class SubmissionCog(commands.Cog):
|
||||||
"""Class holds command for submitting a score."""
|
"""Class holds command for submitting a score."""
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import time
|
|||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from database.db import engine
|
||||||
|
from database.models import Category, CategoryGroup, Guild, Score
|
||||||
from sqlalchemy import distinct, select
|
from sqlalchemy import distinct, select
|
||||||
from sqlalchemy.orm import Session, aliased
|
from sqlalchemy.orm import Session, aliased
|
||||||
from sqlmodel import col
|
from sqlmodel import col
|
||||||
|
|
||||||
from database.db import engine
|
from agon.app import agon_logger
|
||||||
from database.models import Category, CategoryGroup, Guild, Score
|
|
||||||
from main import agon_logger
|
|
||||||
|
|
||||||
MAX_LINE_LENGTH = 142
|
MAX_LINE_LENGTH = 142
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user