Change delete_scores to a slash command.
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
Bot command for deleting the guild's scores.
|
Bot command for deleting the guild's scores.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nextcord import Embed
|
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
import nextcord
|
||||||
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
from highscores import highscores_data # pylint: disable=import-error
|
||||||
|
|
||||||
@@ -14,29 +14,38 @@ class DeleteScores(commands.Cog, name="Delete Scores"):
|
|||||||
Deletes this guild's scores.
|
Deletes this guild's scores.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self):
|
||||||
self.bot = bot
|
"""
|
||||||
|
Default constructor for DeleteScores class. Does nothing.
|
||||||
|
"""
|
||||||
|
|
||||||
@commands.command(name="delete-scores")
|
@nextcord.slash_command(
|
||||||
@commands.has_permissions(administrator=True)
|
description="Deletes all scores for this guild. Used for testing.",
|
||||||
async def delete_scores(self, ctx: commands.Context):
|
default_member_permissions=nextcord.Permissions(administrator=True),
|
||||||
"""A command which deletes all scores for this guild.
|
)
|
||||||
Usage:
|
async def delete_scores(self, interaction: nextcord.Interaction):
|
||||||
```
|
"""
|
||||||
?delete_scores
|
A command which deletes all scores in all tables for this guild.
|
||||||
```
|
Command limits to admins to prevent devs from usings on non-test servers.
|
||||||
"""
|
"""
|
||||||
# only allow AlwaysCompiling to use.
|
# only allow AlwaysCompiling to use.
|
||||||
# If you are a developer and want to use command, can add name to list
|
# If you are a developer and want to use command, can add name to list
|
||||||
if ctx.author.id == 206602713511886849:
|
if interaction.user.id == 206602713511886849:
|
||||||
for table in highscores_data.get_guild(ctx.guild.id).tables:
|
for table in highscores_data.get_guild(interaction.guild_id).tables:
|
||||||
for category in table.categories:
|
for category in table.categories:
|
||||||
category.clear()
|
category.clear()
|
||||||
highscores_data.save_guild_data(highscores_data.get_guild(ctx.guild.id))
|
highscores_data.save_guild_data(highscores_data.get_guild(interaction.guild_id))
|
||||||
|
await interaction.response.send_message(
|
||||||
|
f"Cleared score data for {interaction.guild.name}.", ephemeral=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(
|
||||||
|
"You shouldn't be using this message.", ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
# This function will be called when this extension is loaded.
|
||||||
# It is necessary to add these functions to the bot.
|
# It is necessary to add these functions to the bot.
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
"""Adds function to bot"""
|
"""Adds function to bot"""
|
||||||
bot.add_cog(DeleteScores(bot))
|
bot.add_cog(DeleteScores())
|
||||||
|
|||||||
Reference in New Issue
Block a user