Compare commits
2
Commits
385129c434
..
v4.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c0997624f | ||
|
|
67090e0d6f |
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
|
|||||||
from cogs.submission.verification_view import VerificationView
|
from cogs.submission.verification_view import VerificationView
|
||||||
from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Submission, engine
|
from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Submission, engine
|
||||||
from main import logger
|
from main import logger
|
||||||
from utilities.utils import GUILDS, autofill_categories, autofill_groups, submit_score
|
from utilities.utils import autofill_categories, autofill_groups, submit_score
|
||||||
|
|
||||||
|
|
||||||
class SubmissionCog(commands.Cog):
|
class SubmissionCog(commands.Cog):
|
||||||
@@ -19,7 +19,7 @@ class SubmissionCog(commands.Cog):
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@nextcord.slash_command(guild_ids=GUILDS)
|
@nextcord.slash_command()
|
||||||
async def submit( # noqa: PLR0913
|
async def submit( # noqa: PLR0913
|
||||||
self,
|
self,
|
||||||
interaction: nextcord.Interaction,
|
interaction: nextcord.Interaction,
|
||||||
@@ -47,6 +47,7 @@ class SubmissionCog(commands.Cog):
|
|||||||
group_id (str): Is SlashOption. Group that the score category belongs in.
|
group_id (str): Is SlashOption. Group that the score category belongs in.
|
||||||
category_id (str): Is SlashOption. Category to submit the score in.
|
category_id (str): Is SlashOption. Category to submit the score in.
|
||||||
score (str): Is SlashOption. The score.
|
score (str): Is SlashOption. The score.
|
||||||
|
proof (nextcord.Attachment): Is SlashOption. Picture to provide proof of score.
|
||||||
username (str, optional): Is SlashOption. Username to associate with the score.
|
username (str, optional): Is SlashOption. Username to associate with the score.
|
||||||
"""
|
"""
|
||||||
# fill out username if not passed in
|
# fill out username if not passed in
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""View for verification buttons."""
|
"""View for verification buttons."""
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from sqlalchemy import select
|
from sqlalchemy import delete, select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from database_setup.sql_data_classes import Submission, engine
|
from database_setup.sql_data_classes import Submission, engine
|
||||||
@@ -19,6 +19,14 @@ class VerificationView(nextcord.ui.View):
|
|||||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission")
|
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission")
|
||||||
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||||
"""Button for denying score submission."""
|
"""Button for denying score submission."""
|
||||||
|
with Session(engine) as session:
|
||||||
|
stmt = (
|
||||||
|
delete(Submission)
|
||||||
|
.where(Submission.GuildId == interaction.guild_id)
|
||||||
|
.where(Submission.MessageId == interaction.message.id)
|
||||||
|
)
|
||||||
|
session.execute(stmt)
|
||||||
|
session.commit()
|
||||||
await interaction.message.delete()
|
await interaction.message.delete()
|
||||||
|
|
||||||
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission")
|
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission")
|
||||||
@@ -41,6 +49,8 @@ class VerificationView(nextcord.ui.View):
|
|||||||
await submit_score(
|
await submit_score(
|
||||||
interaction, submission.GroupId, submission.CategoryId, submission.UserName, submission.Score
|
interaction, submission.GroupId, submission.CategoryId, submission.UserName, submission.Score
|
||||||
)
|
)
|
||||||
|
session.delete(submission)
|
||||||
|
session.commit()
|
||||||
content = interaction.message.content
|
content = interaction.message.content
|
||||||
content += f"\nApproved by <@{interaction.user.id}>."
|
content += f"\nApproved by <@{interaction.user.id}>."
|
||||||
# remove the bot information embed. it should always be the first one.
|
# remove the bot information embed. it should always be the first one.
|
||||||
|
|||||||
+2
-5
@@ -1,6 +1,4 @@
|
|||||||
"""
|
"""Contains various utility functions for highscores bot."""
|
||||||
Contains various utlity functions for highscores bot
|
|
||||||
"""
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -14,12 +12,11 @@ from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Scor
|
|||||||
|
|
||||||
MAX_LINE_LENGTH = 142
|
MAX_LINE_LENGTH = 142
|
||||||
|
|
||||||
GUILDS = [1000247361639030804]
|
|
||||||
|
|
||||||
|
|
||||||
def autofill_categories(guild_id: int, group_id: int, category_begin: str) -> "dict[str, str]":
|
def autofill_categories(guild_id: int, group_id: int, category_begin: str) -> "dict[str, str]":
|
||||||
"""
|
"""
|
||||||
Returns all category names that start with category_begin.
|
Returns all category names that start with category_begin.
|
||||||
|
|
||||||
If category_begin is empty, returns list of all category names.
|
If category_begin is empty, returns list of all category names.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
Reference in New Issue
Block a user