Remove score command. It isn't used.
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
"""
|
|
||||||
Bot command to submit a score
|
|
||||||
"""
|
|
||||||
|
|
||||||
from nextcord.ext import commands
|
|
||||||
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
|
||||||
from .verification_view import VerificationView
|
|
||||||
|
|
||||||
|
|
||||||
class Score(commands.Cog, name="Score"):
|
|
||||||
"""Submits a 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.
|
|
||||||
Gathers required information from command and passes on.
|
|
||||||
Usage:
|
|
||||||
```
|
|
||||||
?score "Boss Name" "Category" "score"
|
|
||||||
This command still works if you prefer to use it over the ui.
|
|
||||||
```
|
|
||||||
"""
|
|
||||||
guild_data = highscores_data[str(ctx.guild.id)]
|
|
||||||
verification_channel_id = guild_data["verification_channel_id"]
|
|
||||||
channel = ctx.guild.get_channel(verification_channel_id)
|
|
||||||
|
|
||||||
error_response = "Registered Verification channel does not exist or was never registered."
|
|
||||||
error_response += "Contact server admins."
|
|
||||||
assert channel is not None, await ctx.send(error_response)
|
|
||||||
|
|
||||||
verification_string = f"{ctx.author.display_name}:{boss_name}:{category}:{score}"
|
|
||||||
|
|
||||||
await channel.send(
|
|
||||||
content=verification_string,
|
|
||||||
files=[await attch.to_file() for attch in ctx.message.attachments],
|
|
||||||
view=VerificationView(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
|
||||||
# It is necessary to add these functions to the bot.
|
|
||||||
def setup(bot: commands.Bot):
|
|
||||||
"""Adds function to bot"""
|
|
||||||
bot.add_cog(Score(bot))
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
"""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-score-command"
|
|
||||||
)
|
|
||||||
async def approve_button(
|
|
||||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
|
||||||
): # pylint: disable=unused-argument
|
|
||||||
"""Button for approving score submission."""
|
|
||||||
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)
|
|
||||||
await interaction.message.delete()
|
|
||||||
await interaction.channel.send(
|
|
||||||
f"Approved: {boss_name} {category} {user} {score}",
|
|
||||||
files=[await attch.to_file() for attch in interaction.message.attachments],
|
|
||||||
)
|
|
||||||
|
|
||||||
@nextcord.ui.button(
|
|
||||||
label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-score-command"
|
|
||||||
)
|
|
||||||
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