Verification button working.
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
Bot command to submit a score
|
||||
"""
|
||||
|
||||
from ast import AsyncFunctionDef
|
||||
from nextcord.ext import commands
|
||||
from utils import highscore_manage # pylint: disable=import-error
|
||||
from highscores import highscores_data # pylint: disable=import-error
|
||||
from utilities.utils import submit_score # pylint: disable=import-error
|
||||
from .verification_view import VerificationView
|
||||
|
||||
|
||||
class Score(commands.Cog, name="Score"):
|
||||
@@ -14,6 +14,11 @@ class Score(commands.Cog, name="Score"):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
"""Called when the cog is loaded"""
|
||||
self.bot.add_view(VerificationView())
|
||||
|
||||
@commands.command(name="score")
|
||||
async def score(self, ctx: commands.Context, boss_name: str, category: str, score: str):
|
||||
"""A command which calls a function to submit the score to highscores.
|
||||
@@ -35,10 +40,9 @@ class Score(commands.Cog, name="Score"):
|
||||
await channel.send(
|
||||
content=verification_string,
|
||||
files=[await attch.to_file() for attch in ctx.message.attachments],
|
||||
view=VerificationView(),
|
||||
)
|
||||
|
||||
# await highscore_manage.submit_score(self, ctx, boss_name, category, score)
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"""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):
|
||||
"""Button for approving score submission."""
|
||||
await interaction.response.send_message("Approved")
|
||||
content = interaction.message.content.split(":")
|
||||
user = content[0]
|
||||
boss_name = content[1]
|
||||
category = content[2]
|
||||
score = content[3]
|
||||
|
||||
await submit_score(interaction, user, boss_name, category, score)
|
||||
|
||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny")
|
||||
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
"""Button for denying score submission."""
|
||||
await interaction.response.send_message("Denied")
|
||||
Reference in New Issue
Block a user