Compare commits
No commits in common. "develop" and "main" have entirely different histories.
163
.gitignore
vendored
@ -1,163 +0,0 @@
|
|||||||
# Bot databases stored as .db
|
|
||||||
*.db
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
downloads/
|
|
||||||
eggs/
|
|
||||||
.eggs/
|
|
||||||
lib/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
share/python-wheels/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
|
||||||
# Usually these files are written by a python script from a template
|
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.nox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
*.py,cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
|
||||||
# .python-version
|
|
||||||
|
|
||||||
# pipenv
|
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
||||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
||||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
||||||
# install all needed dependencies.
|
|
||||||
#Pipfile.lock
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
||||||
#poetry.lock
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
||||||
#pdm.lock
|
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
||||||
# in version control.
|
|
||||||
# https://pdm.fming.dev/#use-with-ide
|
|
||||||
.pdm.toml
|
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
||||||
__pypackages__/
|
|
||||||
|
|
||||||
# Celery stuff
|
|
||||||
celerybeat-schedule
|
|
||||||
celerybeat.pid
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env/
|
|
||||||
venv/
|
|
||||||
ENV/
|
|
||||||
env.bak/
|
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
|
||||||
.spyderproject
|
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
.dmypy.json
|
|
||||||
dmypy.json
|
|
||||||
|
|
||||||
# Pyre type checker
|
|
||||||
.pyre/
|
|
||||||
|
|
||||||
# pytype static type analyzer
|
|
||||||
.pytype/
|
|
||||||
|
|
||||||
# Cython debug symbols
|
|
||||||
cython_debug/
|
|
||||||
|
|
||||||
# PyCharm
|
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
||||||
#.idea/
|
|
||||||
@ -15,10 +15,6 @@ Source Code:
|
|||||||
https://github.com/jtkick/base-discord-bot
|
https://github.com/jtkick/base-discord-bot
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# BOT PERMISSIONS
|
|
||||||
# 1729383718059856
|
|
||||||
|
|
||||||
PROJECT_VERSION = "0.1.0"
|
PROJECT_VERSION = "0.1.0"
|
||||||
|
|
||||||
# Standard imports
|
# Standard imports
|
||||||
@ -29,7 +25,6 @@ import sys
|
|||||||
# Third-part imports
|
# Third-part imports
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord import app_commands
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
@ -77,8 +72,6 @@ def main():
|
|||||||
if filename.endswith('.py'):
|
if filename.endswith('.py'):
|
||||||
await client.load_extension(f'cogs.{filename[:-3]}')
|
await client.load_extension(f'cogs.{filename[:-3]}')
|
||||||
logger.info("Loaded %s cog", filename)
|
logger.info("Loaded %s cog", filename)
|
||||||
for server in client.guilds:
|
|
||||||
await client.tree.sync(guild=discord.Object(id=server.id))
|
|
||||||
|
|
||||||
client.run(TOKEN, log_handler=None)
|
client.run(TOKEN, log_handler=None)
|
||||||
|
|
||||||
|
|||||||
BIN
assets/dj.png
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.2 KiB |
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from .icons import colors, generate_pngs
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import cairosvg
|
|
||||||
import codecs
|
|
||||||
import discord
|
|
||||||
import inspect
|
|
||||||
import pathlib
|
|
||||||
import PIL
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
# I need a list of all colors that the Discord library offers, and I can't seem
|
|
||||||
# to find a good one, so I'm going to just create one here
|
|
||||||
colors = ['ash_embed', 'ash_theme', 'blue', 'blurple', 'brand_green',
|
|
||||||
'brand_red', 'dark_blue', 'dark_embed', 'dark_gold', 'dark_gray',
|
|
||||||
'dark_green', 'dark_grey', 'dark_magenta', 'dark_orange', 'dark_purple',
|
|
||||||
'dark_red', 'dark_teal', 'dark_theme', 'darker_gray', 'darker_grey',
|
|
||||||
'default', 'fuchsia', 'gold', 'green', 'greyple', 'light_embed',
|
|
||||||
'light_gray', 'light_grey', 'light_theme', 'lighter_gray',
|
|
||||||
'lighter_grey', 'magenta', 'og_blurple', 'onyx_embed', 'onyx_theme',
|
|
||||||
'orange', 'pink', 'purple', 'red', 'teal', 'yellow']
|
|
||||||
|
|
||||||
def generate_pngs(svg_path: pathlib.Path, png_path: pathlib.Path):
|
|
||||||
"""Generate icons for embed messages.
|
|
||||||
|
|
||||||
This method takes SVG files, changes their colors, and converts them into
|
|
||||||
PNG files for use in Discord message embeds. Since uploading the image
|
|
||||||
itself to the Discord message isn't an option, we are going to create a
|
|
||||||
designated directory for the icons, and use the public URL for it to point
|
|
||||||
Discord to the proper icon.
|
|
||||||
|
|
||||||
Params:
|
|
||||||
svg_path (pathlib.Path): The path to the SVG files to be converted.
|
|
||||||
png_path (pathlib.Path): The path to store the resultant PNG files.
|
|
||||||
"""
|
|
||||||
# Convert to each Discord color
|
|
||||||
for color_name in colors:
|
|
||||||
color_dir = png_path / color_name
|
|
||||||
color_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
color_hex = str(getattr(discord.Colour, color_name)())
|
|
||||||
|
|
||||||
# Open each SVG in the directory
|
|
||||||
for svg_file in svg_path.glob("*.svg"):
|
|
||||||
with codecs.open(svg_file, "r", encoding="utf-8") as f:
|
|
||||||
svg_data = f.read()
|
|
||||||
|
|
||||||
# Convert the SVG elements to the correct new color
|
|
||||||
svg_data = svg_data.replace("#000000", color_hex)
|
|
||||||
|
|
||||||
# If we just save the new PNG, the icon will completely fill the
|
|
||||||
# image, but we're going to use it in areas of Discord messages
|
|
||||||
# where they are rendered in circles, so we're going to add margins
|
|
||||||
# on each side so that the icon doesn't get cut off
|
|
||||||
with tempfile.NamedTemporaryFile(delete=True) as temp:
|
|
||||||
cairosvg.svg2png(
|
|
||||||
bytestring=svg_data.encode("utf-8"), write_to=temp.name)
|
|
||||||
# Resize to add border
|
|
||||||
img = PIL.Image.open(temp.name).convert("RGBA")
|
|
||||||
img = PIL.ImageOps.expand(img, border=100, fill=(0, 0, 0, 0))
|
|
||||||
img.resize((300, 300), PIL.Image.LANCZOS)
|
|
||||||
|
|
||||||
# Save to actual PNG file
|
|
||||||
img.save(color_dir / f"{svg_file.stem}.png", format="PNG")
|
|
||||||
print("new file:", color_dir / f"{svg_file.stem}.png")
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |