Bug fixes from testing post_highscore_groups. Command name change.
This commit is contained in:
@@ -79,7 +79,7 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
|
|||||||
description="Triggers post/update of highscores to registered highscore channel.",
|
description="Triggers post/update of highscores to registered highscore channel.",
|
||||||
default_member_permissions=nextcord.Permissions(administrator=True),
|
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.
|
A command which posts the highscore in the registered channel.
|
||||||
Sends warning if no channel has been registered.
|
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)
|
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):
|
for group in session.scalars(stmt):
|
||||||
channel = interaction.guild.get_channel(group.ChannelId)
|
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.'
|
error_response += 'Use "/register" to register channels.'
|
||||||
assert channel is not None, await interaction.response(error_response, ephemeral=True)
|
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)
|
message: nextcord.Message = await send_highscore_message(channel, group)
|
||||||
await message.edit(view=SubmissionCreateButton(self.bot))
|
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(
|
@nextcord.slash_command(
|
||||||
description="Manually refresh a table. Use when changing settings or data manually changed.",
|
description="Manually refresh a table. Use when changing settings or data manually changed.",
|
||||||
|
|||||||
+2
-2
@@ -175,7 +175,7 @@ def format_highscore_message(group: CategoryGroup) -> str:
|
|||||||
"""
|
"""
|
||||||
ret_string = f"**{group.GroupName}**\n```"
|
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()
|
guild = session.scalars(stmt).one()
|
||||||
|
|
||||||
# Get all categories in the group
|
# Get all categories in the group
|
||||||
@@ -266,7 +266,7 @@ def format_highscore_message(group: CategoryGroup) -> str:
|
|||||||
for string in str_list:
|
for string in str_list:
|
||||||
# rstrip to clear unneeded spaces
|
# rstrip to clear unneeded spaces
|
||||||
# add newline here for each string
|
# add newline here for each string
|
||||||
print(string.rstrip())
|
ret_string += string.rstrip() + "\n"
|
||||||
|
|
||||||
return ret_string + "```"
|
return ret_string + "```"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user