From 158e53e799e6c6b9f0e8ad29da33352e838220ef Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Fri, 22 Jul 2022 22:09:09 -0400 Subject: [PATCH] Add on_guild_remove listener. --- cogs/guild_listener/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cogs/guild_listener/__init__.py b/cogs/guild_listener/__init__.py index f9e1822..fc1b920 100644 --- a/cogs/guild_listener/__init__.py +++ b/cogs/guild_listener/__init__.py @@ -25,9 +25,16 @@ class GuildListener(commands.Cog, name="Guild Listener"): welcome_message: str = "Hello, I keep track of Highscores for you!" welcome_message += "Currently only supporting RuneScape boss highscores, but will be more dynamic support in future." - welcome_message += "For assistance on getting started, use \?register help\." + welcome_message += 'For assistance on getting started, use "?register help".' - guild.system_channel.send(content=welcome_message) + await guild.system_channel.send(content=welcome_message) + + @commands.Cog.listener() + async def on_guild_remove(self, guild: nextcord.Guild): + """Listener for Guild Remove. Removes data from highscores_data.""" + print(f"Removing data for guild {guild.name} (id {guild.id}).") + highscores_data.pop(str(guild.id)) + save_highscores_data(highscores_data) # This function will be called when this extension is loaded.