Archived
generated from imcompiling/discord-bot-template
This commit is contained in:
Vendored
+1
-2
@@ -8,9 +8,8 @@
|
|||||||
"name": "Python: Module",
|
"name": "Python: Module",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "main",
|
"module": "off_cooldown_bot",
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"cwd": "${workspaceFolder}/off_cooldown_bot"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+1
-1
@@ -9,4 +9,4 @@ COPY . /home
|
|||||||
WORKDIR /home
|
WORKDIR /home
|
||||||
RUN uv sync --frozen --no-dev
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
CMD ["uv", "--directory", "./off_cooldown_bot", "run", "main.py"]
|
CMD ["uv", "run", "python", "-m", "off_cooldown_bot"]
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
"""Starts the app for off_cooldown_bot."""
|
||||||
|
|
||||||
|
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()
|
||||||
@@ -2,24 +2,18 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from logger import ocd_logger
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
from settings import settings
|
|
||||||
|
|
||||||
nextcord_logger = logging.getLogger("nextcord")
|
from .logger import ocd_logger
|
||||||
nextcord_logger.setLevel(logging.DEBUG)
|
from .settings import settings
|
||||||
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)
|
|
||||||
|
|
||||||
birthday_list: list[int] = []
|
birthday_list: list[int] = []
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def run() -> None:
|
||||||
"""Set config, intents, then connects the bot to discord."""
|
"""Set config, intents, then connects the bot to discord."""
|
||||||
# Allows privileged intents for monitoring members joining, roles editing, and role assignments
|
# Allows privileged intents for monitoring members joining, roles editing, and role assignments
|
||||||
# These need to be enabled in the developer portal as well
|
# These need to be enabled in the developer portal as well
|
||||||
@@ -37,8 +31,8 @@ def main() -> None:
|
|||||||
bot = commands.Bot(intents=intents)
|
bot = commands.Bot(intents=intents)
|
||||||
|
|
||||||
# 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 pathlib.Path("cogs").iterdir():
|
for folder in pathlib.Path("./off_cooldown_bot/cogs").iterdir():
|
||||||
bot.load_extension(f"cogs.{folder.name}")
|
bot.load_extension(f"off_cooldown_bot.cogs.{folder.name}")
|
||||||
|
|
||||||
@bot.listen()
|
@bot.listen()
|
||||||
async def on_ready() -> None:
|
async def on_ready() -> None:
|
||||||
@@ -50,7 +44,3 @@ def main() -> None:
|
|||||||
|
|
||||||
# Run Discord bot
|
# Run Discord bot
|
||||||
bot.run(settings.params.discord_token)
|
bot.run(settings.params.discord_token)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -3,13 +3,13 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from main import birthday_list
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
from pytz import UTC
|
from pytz import UTC
|
||||||
from sqlmodel import Session, col, select
|
from sqlmodel import Session, col, select
|
||||||
|
|
||||||
from database.db import engine
|
from off_cooldown_bot.app import birthday_list
|
||||||
from database.models import UserBirthday
|
from off_cooldown_bot.database.db import engine
|
||||||
|
from off_cooldown_bot.database.models import UserBirthday
|
||||||
|
|
||||||
|
|
||||||
class BirthdayCog(commands.Cog, name="Birthday Commands"):
|
class BirthdayCog(commands.Cog, name="Birthday Commands"):
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
from datetime import UTC, datetime, time
|
from datetime import UTC, datetime, time
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from logger import ocd_logger
|
|
||||||
from main import birthday_list
|
|
||||||
from nextcord.ext import commands, tasks
|
from nextcord.ext import commands, tasks
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
from settings import settings
|
|
||||||
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 database.db import engine
|
from off_cooldown_bot.app import birthday_list
|
||||||
from database.models import UserBirthday
|
from off_cooldown_bot.database.db import engine
|
||||||
|
from off_cooldown_bot.database.models import UserBirthday
|
||||||
|
from off_cooldown_bot.logger import ocd_logger
|
||||||
|
from off_cooldown_bot.settings import settings
|
||||||
|
|
||||||
|
|
||||||
class DailyLoop(commands.Cog, name="Daily Loop"):
|
class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
"""Defines cog for on message listener."""
|
"""Defines cog for on message listener."""
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from main import birthday_list
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
|
from off_cooldown_bot.app import birthday_list
|
||||||
|
|
||||||
|
|
||||||
class SubmissionListener(commands.Cog, name="Message Listener"):
|
class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||||
"""Sets up message listener."""
|
"""Sets up message listener."""
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from sqlmodel import SQLModel, create_engine
|
|||||||
|
|
||||||
from . import models # noqa: F401 - Need this import for creating the models.
|
from . import models # noqa: F401 - Need this import for creating the models.
|
||||||
|
|
||||||
url = "sqlite:///database.db"
|
url = "sqlite:///database/database.db"
|
||||||
engine = create_engine(url)
|
engine = create_engine(url)
|
||||||
|
|
||||||
SQLModel.metadata.create_all(engine)
|
SQLModel.metadata.create_all(engine)
|
||||||
|
|||||||
Reference in New Issue
Block a user