Saving guild after modification.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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,"
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user