Template
Compare commits
65
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c22d62bfec | ||
|
|
090388cbf3 | ||
|
|
64d5ceda03 | ||
|
|
8f6ab7d01a | ||
|
|
c6750e5dbe | ||
|
|
1e4a300306 | ||
|
|
3ffd739124 | ||
|
|
2d595e1a96 | ||
|
|
6eebce3f2c | ||
|
|
b08185d943 | ||
|
|
8ecd804c90 | ||
|
|
21069fa3db | ||
|
|
8a06ebd795 | ||
|
|
bb54fe775b | ||
|
|
380741e8f1 | ||
|
|
2ea4f83b44 | ||
|
|
0627803734 | ||
|
|
146d8e2230 | ||
|
|
6593c7b63e | ||
|
|
1f60098039 | ||
|
|
0ded9fe60e | ||
|
|
55f295a40b | ||
|
|
ad22747130 | ||
|
|
7f3c1f06ad | ||
|
|
98fa35db7e | ||
|
|
24c32202a0 | ||
|
|
d5acfe3bc2 | ||
|
|
bb6fe8d428 | ||
|
|
22e624f3ab | ||
|
|
ae326f0688 | ||
|
|
1d77adb2d5 | ||
|
|
5d6a261fa6 | ||
|
|
d056b96fa1 | ||
|
|
7446f81219 | ||
|
|
b5060e1347 | ||
|
|
32fe2f7375 | ||
|
|
fa20e99bed | ||
|
|
e55ead2f09 | ||
|
|
4d35d0238e | ||
|
|
b24c0c49fe | ||
|
|
7897a9bd5c | ||
|
|
2dfc29adbf | ||
|
|
ca2e558746 | ||
|
|
229364faf6 | ||
|
|
ad51e3471b | ||
|
|
3b77cbdece | ||
|
|
6f65ae0d91 | ||
|
|
582ec6a5f0 | ||
|
|
1c34d5b87a | ||
|
|
3a3e986f0c | ||
|
|
cb4e4c5522 | ||
|
|
341298f015 | ||
|
|
b64f0bd423 | ||
|
|
da76f5dc0e | ||
|
|
56406de693 | ||
|
|
5edd4e9a0c | ||
|
|
b47a7f2282 | ||
|
|
3986230f46 | ||
|
|
5e43b1f804 | ||
|
|
14903a3c3c | ||
|
|
bae29c8485 | ||
|
|
2ffc24eb86 | ||
|
|
9121627d12 | ||
|
|
c6224282f6 | ||
|
|
edbc8de473 |
@@ -0,0 +1 @@
|
||||
"""Empty init file for ${REPO_NAME_SNAKE} 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()
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Main file for bot."""
|
||||
|
||||
import os
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from .settings import settings
|
||||
|
||||
|
||||
def run() -> None:
|
||||
"""Set config, intents, then connects the bot to discord."""
|
||||
# Allows privileged intents for monitoring members joining, roles editing, and role assignments
|
||||
# These need to be enabled in the developer portal as well
|
||||
intents = nextcord.Intents.default()
|
||||
|
||||
# Required in order to read messages (eg. prefix commands)
|
||||
intents.message_content = True
|
||||
|
||||
# To enable the guilds privileged intent:
|
||||
# intents.guilds = True
|
||||
|
||||
# To enable the members privileged intent:
|
||||
# intents.members = True
|
||||
|
||||
bot = commands.Bot(intents=intents)
|
||||
|
||||
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
|
||||
for folder in os.listdir(f"${REPO_NAME_SNAKE}/cogs"):
|
||||
bot.load_extension(f"${REPO_NAME_SNAKE}.cogs.{folder}")
|
||||
|
||||
@bot.listen()
|
||||
async def on_ready() -> None:
|
||||
"""When Discord is connected."""
|
||||
if bot.user is None:
|
||||
print("Discord connection failed.")
|
||||
return
|
||||
print(f"{bot.user.name} has connected to Discord!")
|
||||
|
||||
# Run Discord bot
|
||||
bot.run(settings.params.discord_token)
|
||||
@@ -1,16 +1,12 @@
|
||||
"""
|
||||
Cog loader. Adds all command cogs to the bot.
|
||||
"""
|
||||
"""Cog loader. Adds all command cogs to the bot."""
|
||||
|
||||
from nextcord.ext import commands
|
||||
|
||||
from cogs.commands.hi import HiCog
|
||||
from .hi import HiCog
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""
|
||||
Adds all command classes to bot.
|
||||
"""
|
||||
def setup(bot: commands.Bot) -> None:
|
||||
"""Add all command classes to bot."""
|
||||
bot.add_cog(HiCog(bot))
|
||||
@@ -1,29 +1,22 @@
|
||||
"""
|
||||
Example command file.
|
||||
"""
|
||||
"""Example command file."""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
|
||||
class HiCog(commands.Cog, name="Test commands."):
|
||||
"""
|
||||
Class holds commands for testing.
|
||||
"""
|
||||
"""Class holds commands for testing."""
|
||||
|
||||
def __init__(self, bot) -> None:
|
||||
"""
|
||||
Default constructor for HelpCog class. Does nothing.
|
||||
"""
|
||||
def __init__(self, bot: commands.Bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@nextcord.slash_command()
|
||||
async def hi(self, interaction: nextcord.Interaction):
|
||||
async def hi(self, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Says hi
|
||||
Says hi.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction to reply to.
|
||||
"""
|
||||
|
||||
"""
|
||||
await interaction.response.send_message("Hi!", ephemeral=True)
|
||||
@@ -0,0 +1,28 @@
|
||||
"""File contains classes defining ${REPO_NAME} settings structure."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from dataclass_wizard import YAMLWizard
|
||||
|
||||
CONFIG_LOCATION = "conf/config.yaml"
|
||||
|
||||
|
||||
@dataclass
|
||||
class Params:
|
||||
"""Class defines start parameters that shouldn't be changed."""
|
||||
|
||||
discord_token: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Settings(YAMLWizard):
|
||||
"""Class defines all configs required for ${REPO_NAME}."""
|
||||
|
||||
params: Params
|
||||
|
||||
def save(self) -> None:
|
||||
"""Save settings to the yaml file."""
|
||||
self.to_yaml_file(CONFIG_LOCATION)
|
||||
|
||||
|
||||
settings = Settings.from_yaml_file(CONFIG_LOCATION)
|
||||
@@ -0,0 +1,2 @@
|
||||
.*
|
||||
Dockerfile
|
||||
@@ -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
|
||||
+4
-2
@@ -1,3 +1,5 @@
|
||||
$REPO_NAME_SNAKE/**
|
||||
.gitea/workflows/*.yml
|
||||
main.py
|
||||
pyproject.toml
|
||||
.vscode/launch.json
|
||||
pyproject.toml
|
||||
Dockerfile
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
name: build_develop
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
- "!main"
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Docker
|
||||
uses: https://github.com/papodaca/install-docker-action@v1
|
||||
- name: Log into container registry
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.cheezers.org
|
||||
username: ${REPO_OWNER}
|
||||
@@ -3,19 +3,21 @@ name: build_latest
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Docker
|
||||
uses: https://github.com/papodaca/install-docker-action@v1
|
||||
- name: Log into container registry
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.cheezers.org
|
||||
username: ${REPO_OWNER}
|
||||
@@ -9,13 +9,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Docker
|
||||
uses: https://github.com/papodaca/install-docker-action@v1
|
||||
- name: Log into container registry
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.cheezers.org
|
||||
username: ${REPO_OWNER}
|
||||
Vendored
+5
-4
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-python.python",
|
||||
"ms-python.debugpy",
|
||||
"charliermarsh.ruff"
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-python.python",
|
||||
"ms-python.debugpy",
|
||||
"charliermarsh.ruff",
|
||||
"editorconfig.editorconfig"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+13
-13
@@ -1,15 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Module",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "main",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Module",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "${REPO_NAME_SNAKE}",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"python.analysis.diagnosticSeverityOverrides": {
|
||||
"reportOptionalMemberAccess": "warning",
|
||||
"reportArgumentType": "information",
|
||||
"reportAttributeAccessIssue": "warning"
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -1,13 +1,12 @@
|
||||
FROM python:3.11.9-slim
|
||||
FROM python:3.13.7-slim
|
||||
|
||||
# install uv
|
||||
COPY --from=ghcr.io/astral-sh/uv:0.13.1 /uv /uvx /bin/
|
||||
|
||||
COPY . /home
|
||||
|
||||
# Sync the project into a new environment, using the frozen lockfile
|
||||
WORKDIR /home
|
||||
RUN uv sync --frozen --no-dev
|
||||
|
||||
COPY config.py config.py
|
||||
COPY main.py main.py
|
||||
COPY pyproject.toml pyproject.toml
|
||||
|
||||
COPY cogs cogs/
|
||||
|
||||
RUN pip install --upgrade pip && pip install poetry && poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt
|
||||
|
||||
CMD ["python3", "-u", "./main.py"]
|
||||
CMD ["uv", "run", "--frozen", "--no-dev", "-m", "${REPO_NAME_SNAKE}"]
|
||||
|
||||
@@ -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
|
||||
@@ -1,65 +0,0 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import hydra
|
||||
import nextcord
|
||||
from hydra.core.config_store import ConfigStore
|
||||
from nextcord.ext import commands
|
||||
|
||||
from config import BotConfig
|
||||
|
||||
cs = ConfigStore.instance()
|
||||
cs.store(name="${REPO_NAME}_config", node=BotConfig)
|
||||
|
||||
logger = logging.getLogger("nextcord")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w")
|
||||
handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
||||
logger.addHandler(handler)
|
||||
|
||||
|
||||
@hydra.main(config_path="conf", config_name="config")
|
||||
def main(cfg: BotConfig):
|
||||
"""
|
||||
Main function for the bot. Sets config, intents, then connects the bot to discord.
|
||||
|
||||
Args:
|
||||
cfg (BotConfig): The local configs to use.
|
||||
"""
|
||||
|
||||
# Allows privledged intents for monitoring members joining, roles editing, and role assignments
|
||||
# These need to be enabled in the developer portal as well
|
||||
intents = nextcord.Intents.default()
|
||||
|
||||
# Required in order to read messages (eg. prefix commands)
|
||||
intents.message_content = True
|
||||
|
||||
# To enable the guilds priveleged intent:
|
||||
# intents.guilds = True
|
||||
|
||||
# To enable the members priveleged intent:
|
||||
# intents.members = True
|
||||
|
||||
bot = commands.Bot(intents=intents)
|
||||
bot.config = cfg
|
||||
|
||||
# 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}")
|
||||
|
||||
@bot.listen()
|
||||
async def on_ready():
|
||||
"""When Discord is connected"""
|
||||
assert bot.user is not None
|
||||
print(f"{bot.user.name} has connected to Discord!")
|
||||
|
||||
# Run Discord bot
|
||||
bot.run(bot.config.params.discord_token)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.argv.append("hydra.job.chdir=False")
|
||||
sys.argv.append("hydra/job_logging=none")
|
||||
sys.argv.append("hydra/hydra_logging=none")
|
||||
main() # pylint: disable=no-value-for-parameter
|
||||
+32
-13
@@ -1,21 +1,20 @@
|
||||
[tool.poetry]
|
||||
[project]
|
||||
name = "${REPO_NAME}"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["${REPO_OWNER}"]
|
||||
authors = [{name="${REPO_OWNER}", email=""}]
|
||||
readme = "README.md"
|
||||
dependencies = [
|
||||
"nextcord>=2.6.0",
|
||||
"sqlmodel>=0.0.22",
|
||||
"dataclass-wizard[yaml]>=0.22.3,<1.0.0",
|
||||
]
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
hydra-core = "1.3.2"
|
||||
nextcord = "2.6.1"
|
||||
python-dotenv = "1.0.0"
|
||||
[tool.uv]
|
||||
dev-dependencies = ["ruff>=0.7.2"]
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.ruff]
|
||||
# Exclude a variety of commonly ignored directories.
|
||||
exclude = [
|
||||
@@ -58,8 +57,28 @@ target-version = "py38"
|
||||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
||||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
||||
# McCabe complexity (`C901`) by default.
|
||||
select = ["E4", "E7", "E9", "F", "D100", "D1"]
|
||||
ignore = ["D107"]
|
||||
select = ["ALL"]
|
||||
ignore = [
|
||||
"B008", # I build SlashOptions as arguments.
|
||||
"COM812",
|
||||
"COM819",
|
||||
"D107", # don't want docstrings on init functions
|
||||
"D203",
|
||||
"D206",
|
||||
"D212",
|
||||
"D300",
|
||||
"E111",
|
||||
"E114",
|
||||
"E117",
|
||||
"ISC001",
|
||||
"ISC002",
|
||||
"PD011", # doesn't like me using '.values' on embeds....
|
||||
"Q000",
|
||||
"Q001",
|
||||
"Q002",
|
||||
"Q003",
|
||||
"W191",
|
||||
]
|
||||
|
||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||
fixable = ["ALL"]
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"lockFileMaintenance": {
|
||||
"automerge": true
|
||||
},
|
||||
"major": {
|
||||
"automerge": false,
|
||||
"automergeType": "pr"
|
||||
},
|
||||
"minor": {
|
||||
"automerge": true,
|
||||
"automergeType": "branch"
|
||||
},
|
||||
"patch": {
|
||||
"automerge": true,
|
||||
"automergeType": "branch"
|
||||
},
|
||||
"pin": {
|
||||
"automerge": true,
|
||||
"automergeType": "branch"
|
||||
},
|
||||
"ignoreTests": true,
|
||||
"dockerfile": {
|
||||
"minor": {
|
||||
"automerge": false,
|
||||
"automergeType": "pr"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
nextcord==2.4.2
|
||||
hydra-core==1.3.2
|
||||
Reference in New Issue
Block a user