Compare commits
5
Commits
1959e11e5c
...
5eb637a3a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eb637a3a8 | ||
|
|
f722eb1a83 | ||
|
|
7759bbc648 | ||
|
|
65de7baeda | ||
|
|
e243404480 |
@@ -50,7 +50,7 @@ class GetCog(commands.Cog, name="Get command."):
|
||||
return
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"{category.name} is sorted in {'ascending' if category.is_ascending else 'descending'} order.",
|
||||
f"**{category.name}** is sorted in **{'ascending' if category.is_ascending else 'descending'}** order.",
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
@@ -109,7 +109,9 @@ class GetCog(commands.Cog, name="Get command."):
|
||||
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
|
||||
return
|
||||
|
||||
await interaction.response.send_message(f"{category.name} has a size of {category.size}.", ephemeral=True)
|
||||
await interaction.response.send_message(
|
||||
f"**{category.name}** has a size of **{category.size}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@get.subcommand(description="Commands for getting group information.")
|
||||
async def group(self, interaction: nextcord.Interaction) -> None:
|
||||
@@ -136,7 +138,7 @@ class GetCog(commands.Cog, name="Get command."):
|
||||
return
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"{group.name} has a pad length of {group.pad_length}.", ephemeral=True
|
||||
f"**{group.name}** has a pad length of **{group.pad_length}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@group.subcommand(description="Get the username length of a group.")
|
||||
@@ -162,7 +164,7 @@ class GetCog(commands.Cog, name="Get command."):
|
||||
return
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"{group.name} has a username length of {group.username_length}.", ephemeral=True
|
||||
f"**{group.name}** has a username length of **{group.username_length}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@is_ascending.on_autocomplete("category_id")
|
||||
|
||||
+17
-12
@@ -22,7 +22,7 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
async def set(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash command for setting settings. Never called."""
|
||||
|
||||
@set.subcommand("Commands for editing a category.")
|
||||
@set.subcommand(description="Commands for editing a category.")
|
||||
async def category(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash subcommand for setting category settings. Never called."""
|
||||
|
||||
@@ -54,7 +54,6 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
|
||||
return
|
||||
category.size = size
|
||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||
session.commit()
|
||||
|
||||
# Use the relationship to get group category is in.
|
||||
@@ -67,7 +66,9 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
return
|
||||
|
||||
await send_highscore_message(session, interaction.guild, group)
|
||||
await interaction.response.send_message(f"{category.name} size has been updated to {size}.", ephemeral=True)
|
||||
await interaction.response.send_message(
|
||||
f"**{category.name}** size has been updated to **{size}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@category.subcommand(description="Update the is_ascending value for a category.")
|
||||
async def is_ascending(
|
||||
@@ -99,7 +100,6 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
|
||||
return
|
||||
category.is_ascending = ascending
|
||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||
session.commit()
|
||||
|
||||
# Use the relationship to get group category is in.
|
||||
@@ -113,7 +113,7 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
|
||||
await send_highscore_message(session, interaction.guild, group)
|
||||
await interaction.response.send_message(
|
||||
f"{category.name} is_ascending has been updated to {ascending}.", ephemeral=True
|
||||
f"**{category.name}** is_ascending has been updated to **{ascending}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@category.subcommand(description="Update the is_validated value for a category.")
|
||||
@@ -146,11 +146,10 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
|
||||
return
|
||||
category.is_validated = validated
|
||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||
session.commit()
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"{category.name} is_validated has been updated to {validated}.", ephemeral=True
|
||||
f"**{category.name}** is_validated has been updated to **{validated}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@category.subcommand(name="name", description="Change the name of a category.")
|
||||
@@ -182,7 +181,6 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
return
|
||||
old_name = category.name
|
||||
category.name = name
|
||||
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
|
||||
session.commit()
|
||||
|
||||
# Use the relationship to get group category is in.
|
||||
@@ -195,7 +193,9 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
return
|
||||
|
||||
await send_highscore_message(session, interaction.guild, group)
|
||||
await interaction.response.send_message(f"{old_name} has been updated to {category.name}.", ephemeral=True)
|
||||
await interaction.response.send_message(
|
||||
f"**{old_name}** has been updated to **{category.name}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@set.subcommand(description="Commands for editing a group.")
|
||||
async def group(self, interaction: nextcord.Interaction) -> None:
|
||||
@@ -228,7 +228,7 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
session.commit()
|
||||
|
||||
await send_highscore_message(session, interaction.guild, group)
|
||||
await interaction.response.send_message(f"{old_name} has been updated to {group.name}.", ephemeral=True)
|
||||
await interaction.response.send_message(f"**{old_name}** has been updated to **{group.name}**.", ephemeral=True)
|
||||
|
||||
@group.subcommand(description="Registers the channel for a Group's messages.")
|
||||
async def output_channel(
|
||||
@@ -264,6 +264,9 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
return
|
||||
group.channel_id = channel_id
|
||||
session.commit()
|
||||
# TODO(imcompiling): delete the message and call send_highscore_message to send a new one. Bug needs fixed
|
||||
# first.
|
||||
# 082
|
||||
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
|
||||
|
||||
@group.subcommand(
|
||||
@@ -302,7 +305,7 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
group.pad_length = length
|
||||
session.commit()
|
||||
await interaction.response.send_message(
|
||||
f"Category pad length set to {length} for {group.name}", ephemeral=True
|
||||
f"Category pad length set to **{length}** for **{group.name}**.", ephemeral=True
|
||||
)
|
||||
await send_highscore_message(session, interaction.guild, group)
|
||||
|
||||
@@ -369,7 +372,9 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
|
||||
group.username_length = length
|
||||
session.commit()
|
||||
await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True)
|
||||
await interaction.response.send_message(
|
||||
f"Username length for **{group.name}** set to **{length}**.", ephemeral=True
|
||||
)
|
||||
|
||||
@set.subcommand(description="Registers the channel for verification messages.")
|
||||
async def verify_channel(
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
from sqlmodel import SQLModel, create_engine
|
||||
from utilities import config
|
||||
from utilities.logger import agon_logger
|
||||
|
||||
from . import models # noqa: F401 - Need this import for creating the models.
|
||||
|
||||
if config.ENVIRONMENT == "prod":
|
||||
url = f"mysql+pymysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
|
||||
agon_logger.info("Connected to prod database.")
|
||||
else:
|
||||
url = "sqlite:///database.db"
|
||||
agon_logger.info("Connected to local dev database.")
|
||||
engine = create_engine(url)
|
||||
|
||||
# Don't need to create all when connected to prod.
|
||||
|
||||
Reference in New Issue
Block a user