Create general autofill table and category util functions. Update table class to have get categories function.

This commit is contained in:
alwayscompiling
2022-11-17 14:50:48 -05:00
parent 1858f0c37d
commit 06b46ef27c
3 changed files with 69 additions and 13 deletions
+6 -13
View File
@@ -9,7 +9,7 @@ import nextcord
from cogs.submission.submission_views import SubmissionCreateButton # pylint: disable=import-error
from highscores import highscores_data # pylint: disable=import-error
from utilities.utils import send_highscore_message # pylint: disable=import-error
from utilities.utils import send_highscore_message, autofill_tables # pylint: disable=import-error
class MessageManagementCog(commands.Cog, name="Message Management"):
@@ -131,7 +131,7 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
await interaction.response.send_message(f"Updated table {table_name}!", ephemeral=True)
@refresh_table.on_autocomplete("table_name")
async def autofill_tables(self, interaction: nextcord.Interaction, table_name: str):
async def refresh_table_autofill(self, interaction: nextcord.Interaction, table_name: str):
"""
Collects list of table names and compares to input table name for autocomplete assistance.
@@ -139,14 +139,7 @@ class MessageManagementCog(commands.Cog, name="Message Management"):
interaction (nextcord.Interaction): Interaction with command.
table (str): String to run autocomplete compared to.
"""
if not table_name:
await interaction.response.send_autocomplete(
highscores_data.get_guild(interaction.guild_id).get_tables().keys()
)
return
near_table = [
name
for name in highscores_data.get_guild(interaction.guild_id).get_tables().keys()
if name.lower().startswith(table_name.lower())
]
await interaction.response.send_autocomplete(near_table)
await interaction.response.send_autocomplete(
autofill_tables(interaction.guild_id, table_name)
)