Add HighscoresData to register command. Add channel setting functions.
This commit is contained in:
@@ -6,7 +6,6 @@ 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
|
||||
|
||||
|
||||
class RegisterVerificationChannel(commands.Cog, name="Register"):
|
||||
@@ -29,17 +28,16 @@ class RegisterVerificationChannel(commands.Cog, name="Register"):
|
||||
"""
|
||||
# respond to the message
|
||||
channel_id = ctx.channel.id
|
||||
guild_data = highscores_data[str(ctx.guild.id)]
|
||||
|
||||
if registration_type == "verify":
|
||||
await ctx.send(f"Registered <#{channel_id}> as channel to post verifications in.")
|
||||
guild_data["verification_channel_id"] = channel_id
|
||||
highscores_data.set_guild_verification_channel(ctx.guild.id, channel_id)
|
||||
elif registration_type == "highscore":
|
||||
await ctx.send(f"Registered <#{channel_id}> as channel to post highscores in.")
|
||||
guild_data["highscore_channel_id"] = channel_id
|
||||
highscores_data.set_guild_highscore_channel(ctx.guild.id, channel_id)
|
||||
elif registration_type == "submission":
|
||||
await ctx.send(f"Registered <#{channel_id}> as channel to post submissions in.")
|
||||
guild_data["submission_channel_id"] = channel_id
|
||||
highscores_data.set_guild_submission_channel(ctx.guild.id, channel_id)
|
||||
else:
|
||||
embed = Embed(
|
||||
title="Register command help", description="How to use the register command."
|
||||
@@ -58,8 +56,6 @@ class RegisterVerificationChannel(commands.Cog, name="Register"):
|
||||
embed.add_field(name="?register help", value="Use to show this message.")
|
||||
await ctx.reply(embed=embed)
|
||||
|
||||
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.
|
||||
|
||||
@@ -197,13 +197,40 @@ class HighscoresData:
|
||||
self._data[str(guild_id)] = guild_data
|
||||
save_highscores_data(self._data)
|
||||
|
||||
def set_guild_highscore_channel(self, guild_id: int, channel_id: int) -> None:
|
||||
"""
|
||||
Sets the guild's highscores channel.
|
||||
|
||||
@param guild_id: guild id to set to.
|
||||
@param channel_id: channel id to set.
|
||||
"""
|
||||
self._data[str(guild_id)]["highscore_channel_id"] = channel_id
|
||||
|
||||
def set_guild_submission_channel(self, guild_id: int, channel_id: int) -> None:
|
||||
"""
|
||||
Sets the guild's submission channel.
|
||||
|
||||
@param guild_id: guild id to set to.
|
||||
@param channel_id: channel id to set.
|
||||
"""
|
||||
self._data[str(guild_id)]["submission_channel_id"] = channel_id
|
||||
|
||||
def set_guild_verification_channel(self, guild_id: int, channel_id: int) -> None:
|
||||
"""
|
||||
Sets the guild's verification channel.
|
||||
|
||||
@param guild_id: guild id to set to.
|
||||
@param channel_id: channel id to set.
|
||||
"""
|
||||
self._data[str(guild_id)]["verification_channel_id"] = channel_id
|
||||
|
||||
def set_table_message_id(self, guild_id: int, table: str, message_id: int) -> None:
|
||||
"""
|
||||
Sets the message id for given guild's table.
|
||||
Saves highscores data.
|
||||
|
||||
@param guild_id: guild id to retrieve from.
|
||||
@param table: the table to retreive from.
|
||||
@param guild_id: guild id to set to.
|
||||
@param table: the table to set to.
|
||||
@param message_id: message id to set.
|
||||
"""
|
||||
self._data[str(guild_id)]["tables"][table]["message_id"] = message_id
|
||||
|
||||
Reference in New Issue
Block a user