Edit embeds to provide bot information for submission.
This commit is contained in:
@@ -52,14 +52,14 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
time_regex = re.search("^([0-9]{1,2}:[0-9]|[0-9])?[0-9](\\.[0-9])?$", message.content)
|
||||
int_regex = re.search("^[0-9]+$", message.content)
|
||||
if time_regex is None and is_time_record:
|
||||
embed = submission_message.embeds[0]
|
||||
embed.add_field(
|
||||
embeds = submission_message.embeds[0]
|
||||
embeds.add_field(
|
||||
name="Error",
|
||||
value="Time record must follow format MM:SS.ms, SS.ms, or SS.",
|
||||
)
|
||||
elif int_regex is None and not is_time_record:
|
||||
embed = submission_message.embeds[0]
|
||||
embed.add_field(name="Error", value="Number record must only be number.")
|
||||
embeds = submission_message.embeds[0]
|
||||
embeds.add_field(name="Error", value="Number record must only be number.")
|
||||
else:
|
||||
score = message.content
|
||||
if is_time_record:
|
||||
@@ -77,9 +77,9 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
# if there is a minute 10ths place 0, remove
|
||||
score = score.lstrip("0")
|
||||
submission.score = score
|
||||
embed = submission.get_embed()
|
||||
embeds = submission.get_embeds()
|
||||
await submission_message.edit(
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
)
|
||||
elif state == SubmissionState.PROOF and len(message.attachments) > 0:
|
||||
await submission_message.edit(
|
||||
@@ -87,9 +87,9 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
)
|
||||
elif state == SubmissionState.NAME and message.content:
|
||||
submission.username = message.content
|
||||
embed = submission.get_embed()
|
||||
embeds = submission.get_embeds()
|
||||
await submission_message.edit(
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
)
|
||||
|
||||
await message.delete()
|
||||
|
||||
@@ -45,9 +45,9 @@ class SubmissionDropdown(nextcord.ui.Select):
|
||||
async def callback(self, interaction: nextcord.Interaction):
|
||||
submission = submission_objects.get_user_submission(interaction.user.id)
|
||||
submission.category_id = self.values[0]
|
||||
embed = submission.get_embed()
|
||||
embeds = submission.get_embeds()
|
||||
await interaction.message.edit(
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
)
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ class BackButton(nextcord.ui.Button):
|
||||
state: SubmissionState = submission.submission_state
|
||||
state = SubmissionState(state.value - 1)
|
||||
submission.submission_state = state
|
||||
embed = submission.get_embed()
|
||||
await interaction.edit(embed=embed, view=SubmissionView(self._bot, interaction.user.id))
|
||||
embeds = submission.get_embeds()
|
||||
await interaction.edit(embeds=embeds, view=SubmissionView(self._bot, interaction.user.id))
|
||||
|
||||
|
||||
class CancelButton(nextcord.ui.Button):
|
||||
@@ -98,8 +98,8 @@ class NextButton(nextcord.ui.Button):
|
||||
else:
|
||||
state = SubmissionState(state.value + 1)
|
||||
submission.submission_state = state
|
||||
embed = submission.get_embed()
|
||||
await interaction.edit(embed=embed, view=SubmissionView(self._bot, interaction.user.id))
|
||||
embeds = submission.get_embeds()
|
||||
await interaction.edit(embeds=embeds, view=SubmissionView(self._bot, interaction.user.id))
|
||||
|
||||
|
||||
class SubmitButton(nextcord.ui.Button):
|
||||
@@ -121,12 +121,12 @@ class SubmitButton(nextcord.ui.Button):
|
||||
|
||||
submission.submission_state = SubmissionState.VERIFY
|
||||
|
||||
embed = submission.get_embed()
|
||||
embeds = submission.get_embeds()
|
||||
|
||||
await channel.send(
|
||||
files=[await attch.to_file() for attch in interaction.message.attachments],
|
||||
view=VerificationView(),
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
content=f"Submission from <@{interaction.user.id}>.",
|
||||
)
|
||||
await interaction.message.edit(content=f"<@{interaction.user.id}> Submitted!", view=None)
|
||||
@@ -170,7 +170,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
||||
|
||||
submission_objects.add_submission(interaction.user.id, submission)
|
||||
|
||||
embed = submission.get_embed()
|
||||
embeds = submission.get_embeds()
|
||||
|
||||
submission_message = await channel.send(
|
||||
f"<@{interaction.user.id}>",
|
||||
@@ -178,7 +178,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
||||
self._bot,
|
||||
interaction.user.id,
|
||||
),
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
)
|
||||
|
||||
# update the message_id once its created
|
||||
|
||||
@@ -24,24 +24,26 @@ class VerificationView(nextcord.ui.View):
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
): # pylint: disable=unused-argument
|
||||
"""Button for approving score submission."""
|
||||
content = interaction.message.embeds[0].to_dict()
|
||||
for embed in interaction.message.embeds:
|
||||
content = embed.to_dict()
|
||||
|
||||
for field in content["fields"]:
|
||||
if field["name"] == "GroupId":
|
||||
group_id = int(field["value"])
|
||||
elif field["name"] == "CategoryId":
|
||||
category_id = int(field["value"])
|
||||
elif field["name"] == "Score":
|
||||
score = float(field["value"])
|
||||
elif field["name"] == "User Name":
|
||||
user = field["value"]
|
||||
for field in content["fields"]:
|
||||
if field["name"] == "GroupId":
|
||||
group_id = int(field["value"])
|
||||
elif field["name"] == "CategoryId":
|
||||
category_id = int(field["value"])
|
||||
elif field["name"] == "Score":
|
||||
score = float(field["value"])
|
||||
elif field["name"] == "User Name":
|
||||
user = field["value"]
|
||||
|
||||
try:
|
||||
|
||||
await submit_score(interaction, group_id, category_id, user, score)
|
||||
content = interaction.message.content
|
||||
content += f"\nApproved by <@{interaction.user.id}>."
|
||||
await interaction.message.edit(content=content, view=None)
|
||||
# remove the bot information embed. it should always be the first one.
|
||||
await interaction.message.edit(content=content, view=None, embed=interaction.message.embeds[0])
|
||||
except UnboundLocalError:
|
||||
await interaction.send("Instruct user to submit with all fields.")
|
||||
await interaction.message.edit(view=None)
|
||||
|
||||
Reference in New Issue
Block a user