Edit embeds to provide bot information for submission.

This commit is contained in:
alwayscompiling
2022-12-01 23:26:04 -05:00
parent 02145ba244
commit 44cb9025b0
4 changed files with 41 additions and 31 deletions
+13 -11
View File
@@ -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)