Compare commits

...
10 changed files with 89 additions and 10 deletions
+21
View File
@@ -0,0 +1,21 @@
FROM python:3.8.10-slim
# install dependencies for mysqlclient
# RUN apt-get update && apt-get -y upgrade && apt-get -y install python3-dev default-libmysqlclient-dev build-essential
RUN pip install --upgrade pip
WORKDIR /home
COPY classes classes/
COPY cogs cogs/
COPY utilities utilities/
COPY highscores.py highscores.py
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# remove build deps that aren't needed to run
# RUN apt-get -y remove python3-dev build-essential && apt-get -y autoremove
CMD ["python3", "./highscores.py"]
+2
View File
@@ -6,6 +6,7 @@ from nextcord.ext import commands
from .create import CreateCog from .create import CreateCog
from .delete import DeleteCog from .delete import DeleteCog
from .help import HelpCog
from .refresh import RefreshCog from .refresh import RefreshCog
from .set import SetCog from .set import SetCog
from .update import UpdateCog from .update import UpdateCog
@@ -19,6 +20,7 @@ def setup(bot: commands.Bot):
""" """
bot.add_cog(CreateCog(bot)) bot.add_cog(CreateCog(bot))
bot.add_cog(DeleteCog()) bot.add_cog(DeleteCog())
bot.add_cog(HelpCog())
bot.add_cog(RefreshCog(bot)) bot.add_cog(RefreshCog(bot))
bot.add_cog(SetCog()) bot.add_cog(SetCog())
bot.add_cog(UpdateCog(bot)) bot.add_cog(UpdateCog(bot))
+47
View File
@@ -0,0 +1,47 @@
"""
Commands for helping a user.
"""
import nextcord
from nextcord.ext import commands
class HelpCog(commands.Cog, name="Help commands."):
"""
Class holds commands for getting help.
"""
def __init__(self) -> None:
"""
Default constructor for HelpCog class. Does nothing.
"""
@nextcord.slash_command()
async def help(self, interaction: nextcord.Interaction):
"""
Parent slash command for help. Never called.
"""
@help.subcommand(description="Describes how to get started with Agon.")
async def setup(self, interaction: nextcord.Interaction):
"""
Sends a message describing how to get started with Agon.
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
"""
# I hate this but don't want indents in the string.
# pylint: disable=line-too-long
help_str: str = """Welcome to Agon! Three simple steps are needed to get started.
1.) Set a channel to recieve submission verifications with "/set verify_channel."
This channel is used to allow moderators to check if a submission is real/valid.
2.) Set a channel for submissions to be posted in with "/set submission_channel."
This channel will be where all user submission messages are sent.
3.) Set up your highscore tables! Use "/create group" to first create a group message in the channel you would like and then use "/create category" to create a category in that group message!"""
# pylint: enable=line-too-long
print(help_str)
await interaction.response.send_message(content=help_str)
+1 -1
View File
@@ -48,7 +48,7 @@ class SetCog(commands.Cog, name="Set command."):
Command function to register a CategoryGroup's output channel. Command function to register a CategoryGroup's output channel.
Args: Args:
interaction (nextcord.Interaction): Interaction that invoked the command interaction (nextcord.Interaction): Interaction that invoked the command.
group_id (str): String representation of Group id to register channel to. Is SlashOption. group_id (str): String representation of Group id to register channel to. Is SlashOption.
channel (nextcord.abc.GuildChannel, optional): Channel to register channel (nextcord.abc.GuildChannel, optional): Channel to register
Is a SlashOption. Limited to text channels, Defaults to None. Is a SlashOption. Limited to text channels, Defaults to None.
+1 -1
View File
@@ -19,7 +19,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_join(self, guild: nextcord.Guild): async def on_guild_join(self, guild: nextcord.Guild):
"""Listener for Guild Join. Creates skeleton for new guild joined and saves it.""" """Listener for Guild Join. Adds guild to database."""
new_guild = Guild(GuildId=guild.id) new_guild = Guild(GuildId=guild.id)
+14 -3
View File
@@ -2,15 +2,26 @@ version: "3"
services: services:
sqldb: sqldb:
restart: unless-stopped restart: unless-stopped
image: "highscores_db" image: mysql:latest
container_name: "Highscores-DataBase" container_name: "Highscores-DataBase"
volumes: volumes:
- highscores_data:/var/lib/mysql - highscores_data:/var/lib/mysql
ports:
- 3306:3306
environment: environment:
- MYSQL_ROOT_PASSWORD=${SQL_PASS} - MYSQL_ROOT_PASSWORD=${SQL_PASS}
- MYSQL_ROOT_USERNAME=${SQL_USER} - MYSQL_ROOT_USERNAME=${SQL_USER}
bot:
restart: unless-stopped
build: .
container_name: "Highscores-Bot"
depends_on:
- sqldb
environment:
- DISCORD_TOKEN=${DISCORD_TOKEN}
- SQL_DB=${SQL_DB}
- SQL_HOST=${SQL_HOST}
- SQL_PASS=${SQL_PASS}
- SQL_USER=${SQL_USER}
volumes: volumes:
highscores_data: highscores_data:
-3
View File
@@ -1,3 +0,0 @@
FROM mysql:latest
COPY highscores_database.sql /docker-entrypoint-initdb.d/
+2 -1
View File
@@ -2,4 +2,5 @@ nextcord>=2.3.2
python-dotenv>=0.20.0 python-dotenv>=0.20.0
pandas>=1.5.2 pandas>=1.5.2
sqlalchemy>=1.4.44 sqlalchemy>=1.4.44
mysqlclient>-2.1.1 pymysql>=1.0.2
cryptography>=2.8
+1 -1
View File
@@ -8,7 +8,7 @@ from sqlalchemy.ext.automap import automap_base
from utilities import config from utilities import config
# connect with sql alchemy and autoload schema # connect with sql alchemy and autoload schema
url = f"mysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}" url = f"mysql+pymysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
engine = create_engine(url) engine = create_engine(url)
Base = automap_base() Base = automap_base()
Base.prepare(autoload_with=engine) Base.prepare(autoload_with=engine)