Cap autocompletion size

pull/122/head
stijndcl 2022-09-25 01:59:55 +02:00
parent eea44fcfa5
commit dd93080199
1 changed files with 2 additions and 2 deletions

View File

@ -40,7 +40,7 @@ class DatabaseCache(ABC):
"""Filter the cache to find everything that matches the search query""" """Filter the cache to find everything that matches the search query"""
query = query.lower() query = query.lower()
# Return the original (non-transformed) version of the data for pretty display in Discord # Return the original (non-transformed) version of the data for pretty display in Discord
suggestions = [self.data[index] for index, value in enumerate(self.data_transformed) if query in value] suggestions = [self.data[index] for index, value in enumerate(self.data_transformed) if query in value][:25]
return [app_commands.Choice(name=suggestion, value=suggestion.lower()) for suggestion in suggestions] return [app_commands.Choice(name=suggestion, value=suggestion.lower()) for suggestion in suggestions]
@ -128,7 +128,7 @@ class UforaCourseCache(DatabaseCache):
if query in alias: if query in alias:
results.add(course) results.add(course)
suggestions = sorted(list(results)) suggestions = sorted(list(results))[:25]
return [app_commands.Choice(name=suggestion, value=suggestion.lower()) for suggestion in suggestions] return [app_commands.Choice(name=suggestion, value=suggestion.lower()) for suggestion in suggestions]