Should have handled username updating code in the command, didn't need to create new functions for the command.
This commit is contained in:
@@ -65,7 +65,8 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
||||
),
|
||||
):
|
||||
"""
|
||||
_summary_
|
||||
Creates a request to send to admins for changing a username. Uses
|
||||
UpdateUsernameVerifyView to do the work.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
|
||||
@@ -54,20 +54,20 @@ class UpdateUsernameVerifyView(nextcord.ui.View):
|
||||
content += f"\nApproved by <@{interaction.user.id}>."
|
||||
await interaction.edit(content=content, view=None)
|
||||
|
||||
tables = guild.update_username(old_username, new_username)
|
||||
# update username in all tables and categories
|
||||
for table in guild.tables:
|
||||
table_updated: bool = False
|
||||
for category in table.categories:
|
||||
score = category.remove_score(old_username)
|
||||
if score:
|
||||
# score exists
|
||||
score.user = new_username
|
||||
category.add_score(score)
|
||||
table_updated = True
|
||||
|
||||
# if no tables updated, send informing message and return.
|
||||
if len(tables) == 0:
|
||||
await interaction.send(
|
||||
f'Username "{old_username}" not found. Have user try again with valid username.',
|
||||
ephemeral=True,
|
||||
)
|
||||
return
|
||||
|
||||
# update all table messages
|
||||
for table in tables:
|
||||
await send_highscore_message(
|
||||
interaction.guild.get_channel(guild.highscore_channel), guild, table
|
||||
)
|
||||
if table_updated:
|
||||
await send_highscore_message(
|
||||
interaction.guild.get_channel(guild.highscore_channel), guild, table
|
||||
)
|
||||
|
||||
highscores_data.save_guild_data(guild)
|
||||
|
||||
Reference in New Issue
Block a user