Create general autofill table and category util functions. Update table class to have get categories function.
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user