Archived
generated from imcompiling/discord-bot-template
Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb5889f7ae | ||
|
|
3c489c83e2 | ||
|
|
aeb00a107f | ||
|
|
c65acb094a | ||
|
|
631c42ac0b | ||
|
|
7811abc33e | ||
|
|
2a01cf09ec | ||
|
|
6d9325c354 | ||
|
|
865802eeeb | ||
|
|
8fce10d9be | ||
|
|
5c6fa4386e | ||
|
|
590cb9abe4 | ||
|
|
46f518c1c4 | ||
|
|
30ecdab8a5 | ||
|
|
565ea73792 | ||
|
|
bfef75870f | ||
|
|
56289e7038 | ||
|
|
54a011337a | ||
|
|
b3905fa15c | ||
|
|
a09845dfb8 | ||
|
|
a86b01292f | ||
|
|
1ad68f4014 | ||
|
|
3aa0bf291f | ||
|
|
b727a80e4f | ||
|
|
857b5f1669 | ||
|
|
34cd2f9975 | ||
|
|
6af2476339 | ||
|
|
4a3f356b23 | ||
|
|
4fe2339ac1 | ||
|
|
2069b2544f | ||
|
|
901bcf3c62 | ||
|
|
8e8f84a42e | ||
|
|
cd241e6f5e | ||
|
|
93d9b565c0 | ||
|
|
c816d3b5b8 | ||
|
|
91900f2b00 |
@@ -0,0 +1,4 @@
|
|||||||
|
.*
|
||||||
|
Dockerfile
|
||||||
|
renovate.json
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# see https://editorconfig.org/
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
@@ -13,13 +13,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
uses: https://github.com/papodaca/install-docker-action@v1
|
uses: https://github.com/papodaca/install-docker-action@v1
|
||||||
- name: Log into container registry
|
- name: Log into container registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: gitea.cheezers.org
|
registry: gitea.cheezers.org
|
||||||
username: imcompiling
|
username: imcompiling
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
uses: https://github.com/papodaca/install-docker-action@v1
|
uses: https://github.com/papodaca/install-docker-action@v1
|
||||||
- name: Log into container registry
|
- name: Log into container registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: gitea.cheezers.org
|
registry: gitea.cheezers.org
|
||||||
username: imcompiling
|
username: imcompiling
|
||||||
password: $${{ secrets.PASSWORD }}
|
password: ${{ secrets.PASSWORD }}
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
run: docker build -t gitea.cheezers.org/imcompiling/off-cooldown-bot:latest .
|
run: docker build -t gitea.cheezers.org/imcompiling/off-cooldown-bot:latest .
|
||||||
- name: Push Docker Image
|
- name: Push Docker Image
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ jobs:
|
|||||||
- name: Set env
|
- name: Set env
|
||||||
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
- name: Build Docker Images
|
- name: Build Docker Images
|
||||||
run: docker build -t gitea.cheezers.org/imcompiling/off-cooldown-bot:latest -t gitea.cheezers.org/imcompiling/off-cooldown-bot:${{env.GIT_TAG}} .
|
run: docker build -t gitea.cheezers.org/imcompiling/off-cooldown-bot:${{env.GIT_TAG}} .
|
||||||
- name: Push Latest Image
|
|
||||||
run: docker push gitea.cheezers.org/imcompiling/off-cooldown-bot:latest
|
|
||||||
- name: Push Tagged Image
|
- name: Push Tagged Image
|
||||||
run: docker push gitea.cheezers.org/imcompiling/off-cooldown-bot:${{env.GIT_TAG}}
|
run: docker push gitea.cheezers.org/imcompiling/off-cooldown-bot:${{env.GIT_TAG}}
|
||||||
|
|||||||
+1
-1
@@ -129,4 +129,4 @@ dmypy.json
|
|||||||
nextcord.log
|
nextcord.log
|
||||||
outputs/
|
outputs/
|
||||||
|
|
||||||
database.db
|
/database
|
||||||
|
|||||||
Vendored
+5
-4
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"ms-python.vscode-pylance",
|
"ms-python.vscode-pylance",
|
||||||
"ms-python.python",
|
"ms-python.python",
|
||||||
"ms-python.debugpy",
|
"ms-python.debugpy",
|
||||||
"charliermarsh.ruff"
|
"charliermarsh.ruff",
|
||||||
|
"editorconfig.editorconfig"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+14
-14
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
// Use IntelliSense to learn about possible attributes.
|
||||||
// Hover to view descriptions of existing attributes.
|
// Hover to view descriptions of existing attributes.
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Python: Module",
|
"name": "Python: Module",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "main",
|
"module": "off_cooldown_bot",
|
||||||
"justMyCode": true
|
"justMyCode": true,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Vendored
+2
-5
@@ -4,8 +4,5 @@
|
|||||||
"reportArgumentType": "information",
|
"reportArgumentType": "information",
|
||||||
"reportAttributeAccessIssue": "warning"
|
"reportAttributeAccessIssue": "warning"
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": ["cakeday", "cakedays", "cooldown", "nextcord"]
|
||||||
"cakeday",
|
}
|
||||||
"cakedays"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
+6
-10
@@ -1,16 +1,12 @@
|
|||||||
FROM python:3.12.3-slim
|
FROM python:3.13.3-slim
|
||||||
|
|
||||||
# install uv
|
# install uv
|
||||||
COPY --from=ghcr.io/astral-sh/uv:0.6.5 /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:0.6.17 /uv /uvx /bin/
|
||||||
|
|
||||||
|
COPY . /home
|
||||||
|
|
||||||
|
# Sync the project into a new environment, using the frozen lockfile
|
||||||
WORKDIR /home
|
WORKDIR /home
|
||||||
|
|
||||||
COPY config.py config.py
|
|
||||||
COPY main.py main.py
|
|
||||||
COPY pyproject.toml pyproject.toml
|
|
||||||
|
|
||||||
COPY cogs cogs/
|
|
||||||
|
|
||||||
RUN uv sync --frozen --no-dev
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
CMD ["uv", "run", "./main.py"]
|
CMD ["uv", "run", "--frozen", "--no-dev", "-m", "off_cooldown_bot"]
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
"""
|
|
||||||
File contains classes defining the Hydra configuraton structure.
|
|
||||||
"""
|
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Params:
|
|
||||||
"""
|
|
||||||
Class defines the various configuration parameters.
|
|
||||||
"""
|
|
||||||
|
|
||||||
discord_token: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class BotConfig:
|
|
||||||
"""
|
|
||||||
Class defines all configs required for Dakiny Bot.
|
|
||||||
"""
|
|
||||||
|
|
||||||
params: Params
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Empty init file for off_cooldown_bot module."""
|
||||||
@@ -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,25 +2,18 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from logger import ocd_logger
|
from .logger import ocd_logger
|
||||||
from settings import settings
|
from .settings import settings
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
||||||
@@ -30,7 +23,7 @@ def main() -> None:
|
|||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
|
||||||
# To enable the guilds privileged intent:
|
# To enable the guilds privileged intent:
|
||||||
# intents.guilds = True
|
# intents.guilds = True # noqa: ERA001
|
||||||
|
|
||||||
# To enable the members privileged intent:
|
# To enable the members privileged intent:
|
||||||
intents.members = True
|
intents.members = True
|
||||||
@@ -38,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:
|
||||||
@@ -47,11 +40,7 @@ def main() -> None:
|
|||||||
if bot.user is None:
|
if bot.user is None:
|
||||||
ocd_logger.critical("Discord connection failed.")
|
ocd_logger.critical("Discord connection failed.")
|
||||||
return
|
return
|
||||||
ocd_logger.info(f"{bot.user.name} has connected to Discord!")
|
ocd_logger.info("%s has connected to Discord!", bot.user.name)
|
||||||
|
|
||||||
# Run Discord bot
|
# Run Discord bot
|
||||||
bot.run(settings.params.discord_token)
|
bot.run(settings.params.discord_token)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from cogs.commands.birthday import BirthdayCog
|
from .birthday import BirthdayCog
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
# This function will be called when this extension is loaded.
|
||||||
@@ -7,9 +7,9 @@ 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 main import birthday_list
|
from off_cooldown_bot.database.models import UserBirthday
|
||||||
|
|
||||||
|
|
||||||
class BirthdayCog(commands.Cog, name="Birthday Commands"):
|
class BirthdayCog(commands.Cog, name="Birthday Commands"):
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from cogs.loops.bot_presence import BotPresence
|
from .bot_presence import BotPresence
|
||||||
from cogs.loops.daily_loop import DailyLoop
|
from .daily_loop import DailyLoop
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: commands.Bot) -> None:
|
def setup(bot: commands.Bot) -> None:
|
||||||
@@ -9,11 +9,11 @@ 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 logger import ocd_logger
|
from off_cooldown_bot.database.models import UserBirthday
|
||||||
from main import birthday_list
|
from off_cooldown_bot.logger import ocd_logger
|
||||||
from settings import settings
|
from off_cooldown_bot.settings import settings
|
||||||
|
|
||||||
|
|
||||||
class DailyLoop(commands.Cog, name="Daily Loop"):
|
class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
import nextcord
|
import nextcord
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from main import birthday_list
|
from off_cooldown_bot.app import birthday_list
|
||||||
|
|
||||||
|
|
||||||
class SubmissionListener(commands.Cog, name="Message Listener"):
|
class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||||
@@ -4,8 +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)
|
||||||
|
|
||||||
# Don't need to create all when connected to prod.
|
|
||||||
SQLModel.metadata.create_all(engine)
|
SQLModel.metadata.create_all(engine)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Creates logger for Agon bot."""
|
"""Creates logger for Off Cooldown bot."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
@@ -35,3 +35,7 @@ class Settings(YAMLWizard):
|
|||||||
|
|
||||||
|
|
||||||
settings = Settings.from_yaml_file(CONFIG_LOCATION)
|
settings = Settings.from_yaml_file(CONFIG_LOCATION)
|
||||||
|
|
||||||
|
# I'm not expecting a list to be returned.
|
||||||
|
if isinstance(settings, list):
|
||||||
|
settings = settings[0]
|
||||||
@@ -6,7 +6,6 @@ authors = [{ name = "imcompiling", email = "[email protected]" }]
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nextcord>=2.6.0",
|
"nextcord>=2.6.0",
|
||||||
"python-dotenv>=1.0.1",
|
|
||||||
"sqlmodel>=0.0.22",
|
"sqlmodel>=0.0.22",
|
||||||
"dataclass-wizard[yaml]>=0.22.3,<1.0.0",
|
"dataclass-wizard[yaml]>=0.22.3,<1.0.0",
|
||||||
"pytz>=2025.1",
|
"pytz>=2025.1",
|
||||||
|
|||||||
@@ -306,7 +306,6 @@ source = { virtual = "." }
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "dataclass-wizard", extra = ["yaml"] },
|
{ name = "dataclass-wizard", extra = ["yaml"] },
|
||||||
{ name = "nextcord" },
|
{ name = "nextcord" },
|
||||||
{ name = "python-dotenv" },
|
|
||||||
{ name = "pytz" },
|
{ name = "pytz" },
|
||||||
{ name = "sqlmodel" },
|
{ name = "sqlmodel" },
|
||||||
]
|
]
|
||||||
@@ -320,7 +319,6 @@ dev = [
|
|||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "dataclass-wizard", extras = ["yaml"], specifier = ">=0.22.3,<1.0.0" },
|
{ name = "dataclass-wizard", extras = ["yaml"], specifier = ">=0.22.3,<1.0.0" },
|
||||||
{ name = "nextcord", specifier = ">=2.6.0" },
|
{ name = "nextcord", specifier = ">=2.6.0" },
|
||||||
{ name = "python-dotenv", specifier = ">=1.0.1" },
|
|
||||||
{ name = "pytz", specifier = ">=2025.1" },
|
{ name = "pytz", specifier = ">=2025.1" },
|
||||||
{ name = "sqlmodel", specifier = ">=0.0.22" },
|
{ name = "sqlmodel", specifier = ">=0.0.22" },
|
||||||
]
|
]
|
||||||
@@ -438,15 +436,6 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/51/b2/b2b50d5ecf21acf870190ae5d093602d95f66c9c31f9d5de6062eb329ad1/pydantic_core-2.27.2-cp313-cp313-win_arm64.whl", hash = "sha256:ac4dbfd1691affb8f48c2c13241a2e3b60ff23247cbcf981759c768b6633cf8b", size = 1885186 },
|
{ url = "https://files.pythonhosted.org/packages/51/b2/b2b50d5ecf21acf870190ae5d093602d95f66c9c31f9d5de6062eb329ad1/pydantic_core-2.27.2-cp313-cp313-win_arm64.whl", hash = "sha256:ac4dbfd1691affb8f48c2c13241a2e3b60ff23247cbcf981759c768b6633cf8b", size = 1885186 },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "python-dotenv"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = { registry = "https://pypi.org/simple" }
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/bc/57/e84d88dfe0aec03b7a2d4327012c1627ab5f03652216c63d49846d7a6c58/python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca", size = 39115 }
|
|
||||||
wheels = [
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/6a/3e/b68c118422ec867fa7ab88444e1274aa40681c606d59ac27de5a5588f082/python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a", size = 19863 },
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytz"
|
name = "pytz"
|
||||||
version = "2025.1"
|
version = "2025.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user