Compare commits
2
Commits
b16132d61b
...
2ad1c808c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ad1c808c2 | ||
|
|
3898e5e494 |
@@ -20,7 +20,7 @@ class SubmissionCog(commands.Cog):
|
||||
return
|
||||
|
||||
@nextcord.slash_command(guild_ids=GUILDS)
|
||||
async def submit(
|
||||
async def submit( # noqa: PLR0913
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
group_id: str = nextcord.SlashOption(name="group", required=True, description="Group to submit score to."),
|
||||
@@ -28,6 +28,9 @@ class SubmissionCog(commands.Cog):
|
||||
name="category", required=True, description="Category to submit score to."
|
||||
),
|
||||
score: str = nextcord.SlashOption(required=True, description="Score to submit"),
|
||||
proof: nextcord.Attachment = nextcord.SlashOption(
|
||||
required=False, description="Proof for submission. Only needed if score requires verification."
|
||||
),
|
||||
username: str = nextcord.SlashOption(
|
||||
required=False, description="Modified username if submitting under not your discord name."
|
||||
),
|
||||
@@ -58,7 +61,7 @@ class SubmissionCog(commands.Cog):
|
||||
category: Category = session.scalar(stmt)
|
||||
|
||||
# check if verification is required. if no picture, deny
|
||||
if category.IsValidated and not len(interaction.message.attachments) > 0:
|
||||
if category.IsValidated and proof is None:
|
||||
await interaction.response.send_message(
|
||||
"This category required verification. Please attach a picture and re-submit.", ephemeral=True
|
||||
)
|
||||
@@ -98,7 +101,7 @@ class SubmissionCog(commands.Cog):
|
||||
|
||||
# Send the verification message to admins
|
||||
verification_message = await channel.send(
|
||||
files=[await attach.to_file() for attach in interaction.message.attachments],
|
||||
file=await proof.to_file(),
|
||||
view=VerificationView(),
|
||||
embeds=[self.create_embed(interaction, group_id, category_id, verified_score, username, session)],
|
||||
content=f"Submission from <@{interaction.user.id}>.",
|
||||
@@ -112,6 +115,7 @@ class SubmissionCog(commands.Cog):
|
||||
GuildId=interaction.guild_id,
|
||||
MessageId=verification_message.id,
|
||||
Score=verified_score,
|
||||
UserId=interaction.user.id,
|
||||
UserName=username,
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class VerificationView(nextcord.ui.View):
|
||||
elif field["name"] == "User Name":
|
||||
user = field["value"]
|
||||
|
||||
# TODO: rework to get the information from database instead
|
||||
|
||||
try:
|
||||
await submit_score(interaction, group_id, category_id, user, score)
|
||||
content = interaction.message.content
|
||||
|
||||
@@ -47,9 +47,10 @@ CREATE TABLE Scores(
|
||||
CREATE TABLE Submissions(
|
||||
CategoryId int unsigned not null,
|
||||
GroupId int unsigned not null,
|
||||
GuildId int unsigned not null,
|
||||
MessageId int unsigned not null,
|
||||
GuildId bigint unsigned not null,
|
||||
MessageId bigint unsigned not null,
|
||||
Score varchar(30) not null, -- Score is stored as a string until converted during submission
|
||||
UserId bigint unsigned not null,
|
||||
UserName varchar(30) not null,
|
||||
PRIMARY KEY (CategoryId, UserName) -- one submission a category per user.
|
||||
);
|
||||
Reference in New Issue
Block a user