Sending to verification view.
This commit is contained in:
@@ -39,7 +39,7 @@ class SubmissionButton(nextcord.ui.View):
|
|||||||
return (
|
return (
|
||||||
interaction.user.id == check_message.author.id
|
interaction.user.id == check_message.author.id
|
||||||
and interaction.channel == check_message.channel
|
and interaction.channel == check_message.channel
|
||||||
) # unsure if comparison is correct
|
) # TODO confirm no-one else can interact with someone's submission
|
||||||
|
|
||||||
proof_message = await self._bot.wait_for("message", check=wait_check)
|
proof_message = await self._bot.wait_for("message", check=wait_check)
|
||||||
embed = submission_message.embeds[0]
|
embed = submission_message.embeds[0]
|
||||||
@@ -75,7 +75,7 @@ class SubmissionDropdown(nextcord.ui.Select):
|
|||||||
embed = interaction.message.embeds[0]
|
embed = interaction.message.embeds[0]
|
||||||
embed.add_field(name="Category", value=self.values[0], inline=False)
|
embed.add_field(name="Category", value=self.values[0], inline=False)
|
||||||
await interaction.message.edit(
|
await interaction.message.edit(
|
||||||
embed=embed,
|
embed=embed, # TODO solve ordering issue. currently have to choose category after score submission.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -95,7 +95,9 @@ class SubmissionDropdownView(nextcord.ui.View):
|
|||||||
self._prev_interaction = prev_interaction
|
self._prev_interaction = prev_interaction
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
async def interaction_check(self, interaction: nextcord.Interaction) -> bool:
|
async def interaction_check(
|
||||||
|
self, interaction: nextcord.Interaction
|
||||||
|
) -> bool: # TODO confirm no-one else can interact with someone's submission
|
||||||
return self._prev_interaction.user == interaction.user
|
return self._prev_interaction.user == interaction.user
|
||||||
|
|
||||||
@nextcord.ui.button(
|
@nextcord.ui.button(
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
"""View for verification buttons"""
|
||||||
|
|
||||||
|
import nextcord
|
||||||
|
from utilities.utils import submit_score # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
|
class VerificationView(nextcord.ui.View):
|
||||||
|
"""Defines views for verifying score submissions"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
|
||||||
|
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve")
|
||||||
|
async def approve_button(
|
||||||
|
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 field in content["fields"]:
|
||||||
|
if field["name"] == "Boss":
|
||||||
|
boss_name = field["value"]
|
||||||
|
elif field["name"] == "Category":
|
||||||
|
category = field["value"]
|
||||||
|
elif field["name"] == "Score":
|
||||||
|
score = field["value"]
|
||||||
|
elif field["name"] == "User":
|
||||||
|
user = field["value"]
|
||||||
|
|
||||||
|
# TODO assert that all fields are filled out
|
||||||
|
await submit_score(interaction, user, boss_name, category, score)
|
||||||
|
await interaction.message.edit("Approved.", view=None)
|
||||||
|
|
||||||
|
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny")
|
||||||
|
async def deny_button(
|
||||||
|
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||||
|
): # pylint: disable=unused-argument
|
||||||
|
"""Button for denying score submission."""
|
||||||
|
await interaction.message.delete()
|
||||||
Reference in New Issue
Block a user