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