Bug fixes from testing post_highscore_groups. Command name change.

This commit is contained in:
alwayscompiling
2022-12-01 20:34:12 -05:00
parent d0f328dd2d
commit 2ec7296c0f
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -79,7 +79,7 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
description="Triggers post/update of highscores to registered highscore channel.",
default_member_permissions=nextcord.Permissions(administrator=True),
)
async def post_highscore_tables(self, interaction: nextcord.Interaction) -> None:
async def post_highscore_groups(self, interaction: nextcord.Interaction) -> None:
"""
A command which posts the highscore in the registered channel.
Sends warning if no channel has been registered.
@@ -92,6 +92,9 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
"""
stmt = select(CategoryGroup).where(CategoryGroup.GuildId == interaction.guild_id)
# awaiting response because posting scores takes a while
await interaction.response.defer(ephemeral=True)
for group in session.scalars(stmt):
channel = interaction.guild.get_channel(group.ChannelId)
@@ -100,13 +103,10 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
error_response += 'Use "/register" to register channels.'
assert channel is not None, await interaction.response(error_response, ephemeral=True)
# awaiting response because posting scores takes a while
await interaction.response.defer(ephemeral=True)
message: nextcord.Message = await send_highscore_message(channel, group)
await message.edit(view=SubmissionCreateButton(self.bot))
await interaction.send(f"Posted all groups in <#{channel.id}>.", ephemeral=True)
await interaction.send(f"Posted all groups in {interaction.guild.name}'s highscores.", ephemeral=True)
@nextcord.slash_command(
description="Manually refresh a table. Use when changing settings or data manually changed.",
+2 -2
View File
@@ -175,7 +175,7 @@ def format_highscore_message(group: CategoryGroup) -> str:
"""
ret_string = f"**{group.GroupName}**\n```"
stmt = select(Guild).where(Guild.GuildId == Category.GuildId)
stmt = select(Guild).where(Guild.GuildId == group.GuildId)
guild = session.scalars(stmt).one()
# Get all categories in the group
@@ -266,7 +266,7 @@ def format_highscore_message(group: CategoryGroup) -> str:
for string in str_list:
# rstrip to clear unneeded spaces
# add newline here for each string
print(string.rstrip())
ret_string += string.rstrip() + "\n"
return ret_string + "```"