diff --git a/cogs/delete_scores/__init__.py b/cogs/delete_scores/__init__.py index 1d4e105..a08b077 100644 --- a/cogs/delete_scores/__init__.py +++ b/cogs/delete_scores/__init__.py @@ -32,6 +32,7 @@ class DeleteScores(commands.Cog, name="Delete Scores"): for table in highscores_data.get_guild(ctx.guild.id).tables: for category in table.categories: category.clear() + highscores_data.save_guild_data(highscores_data.get_guild(ctx.guild.id)) # This function will be called when this extension is loaded. diff --git a/cogs/guild_listener/__init__.py b/cogs/guild_listener/__init__.py index 418d509..4ea0f6b 100644 --- a/cogs/guild_listener/__init__.py +++ b/cogs/guild_listener/__init__.py @@ -18,6 +18,7 @@ class GuildListener(commands.Cog, name="Guild Listener"): async def on_guild_join(self, guild: nextcord.Guild): """Listener for Guild Join. Creates skeleton for new guild joined and saves it.""" highscores_data.add_guild(guild.id) + highscores_data.save_guild_data(highscores_data.get_guild(guild.id)) welcome_message: str = "Hello, I keep track of Highscores for you!" welcome_message += " Currently only supporting RuneScape boss highscores," diff --git a/cogs/register/__init__.py b/cogs/register/__init__.py index 669dc07..d9c6e73 100644 --- a/cogs/register/__init__.py +++ b/cogs/register/__init__.py @@ -11,12 +11,12 @@ from highscores import highscores_data # pylint: disable=import-error class RegisterVerificationChannel(commands.Cog, name="Register"): """Bot command for registering various channels to the bot.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: commands.Bot) -> None: self.bot = bot @commands.command(name="register") @commands.has_permissions(administrator=True) - async def register_highscores(self, ctx: commands.Context, registration_type: str): + async def register_highscores(self, ctx: commands.Context, registration_type: str) -> None: """A command which registers current channel as for various uses. Usage: ``` @@ -28,16 +28,17 @@ class RegisterVerificationChannel(commands.Cog, name="Register"): """ # respond to the message channel_id = ctx.channel.id + guild = highscores_data.get_guild(ctx.guild.id) if registration_type == "verify": await ctx.send(f"Registered <#{channel_id}> as channel to post verifications in.") - highscores_data.get_guild(ctx.guild.id).verification_channel = channel_id + guild.verification_channel = channel_id elif registration_type == "highscore": await ctx.send(f"Registered <#{channel_id}> as channel to post highscores in.") - highscores_data.get_guild(ctx.guild.id).highscore_channel = channel_id + guild.highscore_channel = channel_id elif registration_type == "submission": await ctx.send(f"Registered <#{channel_id}> as channel to post submissions in.") - highscores_data.get_guild(ctx.guild.id).submission_channel = channel_id + guild.submission_channel = channel_id else: embed = Embed( title="Register command help", description="How to use the register command." @@ -55,10 +56,14 @@ class RegisterVerificationChannel(commands.Cog, name="Register"): ) embed.add_field(name="?register help", value="Use to show this message.") await ctx.reply(embed=embed) + # return, don't need to save data + return + + highscores_data.save_guild_data(guild) # 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): +def setup(bot: commands.Bot) -> None: """Adds function to bot""" bot.add_cog(RegisterVerificationChannel(bot)) diff --git a/utilities/utils.py b/utilities/utils.py index ca20af9..6852f8f 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -3,7 +3,7 @@ Contains various utlity functions for highscores bot """ import nextcord -from highscores import highscores_message_map # pylint: disable=import-error +from highscores import highscores_data, highscores_message_map # pylint: disable=import-error from data.score import Score # pylint: disable=import-error from data.guild import Guild # pylint: disable=import-error from data.category import Category # pylint: disable=import-error @@ -112,6 +112,7 @@ async def submit_score( """ category.add_score(score) + highscores_data.save_guild_data(guild) # edit message print(f"Editting message {guild.highscore_channel}")