Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
790e8ca50f | ||
|
|
7ba43ea4f4 |
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
Bot command for deleting the guild's scores.
|
||||
"""
|
||||
|
||||
from nextcord import Embed
|
||||
from nextcord.ext import commands
|
||||
|
||||
from highscores import highscores_data # pylint: disable=import-error
|
||||
from utilities.data_storage import save_highscores_data # pylint: disable=import-error
|
||||
from utilities.data_storage import create_highscore_skeleton # pylint: disable=import-error
|
||||
|
||||
|
||||
class DeleteScores(commands.Cog, name="Delete Scores"):
|
||||
"""
|
||||
Warning: This command only works for developers.
|
||||
Deletes this guild's scores.
|
||||
"""
|
||||
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(name="delete-scores")
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def delete_scores(self, ctx: commands.Context):
|
||||
"""A command which registers current channel as for various uses.
|
||||
Usage:
|
||||
```
|
||||
?delete_scores
|
||||
```
|
||||
"""
|
||||
# only allow AlwaysCompiling to use.
|
||||
# If you are a developer and want to use command, can add name to list
|
||||
if ctx.author.id == 206602713511886849:
|
||||
guild_data: dict = highscores_data[str(ctx.guild.id)]
|
||||
|
||||
for boss, boss_data in guild_data["tables"].items():
|
||||
for category, category_data in boss_data["categories"].items():
|
||||
category_data = []
|
||||
boss_data["categories"][category] = category_data
|
||||
guild_data["tables"][boss] = boss_data
|
||||
|
||||
save_highscores_data(highscores_data)
|
||||
|
||||
|
||||
# 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(DeleteScores(bot))
|
||||
@@ -75,6 +75,9 @@ async def send_highscore_message(
|
||||
# save message -> boss_name in message_map
|
||||
# get guild id from channel
|
||||
# channel should come from the guild that is requesting this highscores message anyways.
|
||||
# check if guild is in message map already
|
||||
if not str(channel.guild.id) in highscores_message_map:
|
||||
highscores_message_map[str(channel.guild.id)] = {}
|
||||
highscores_message_map[str(channel.guild.id)][message_id] = boss_name
|
||||
|
||||
return message
|
||||
|
||||
Reference in New Issue
Block a user