aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/search.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/search.py')
-rw-r--r--cogs/search.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/cogs/search.py b/cogs/search.py
index 2f8373b..a124cbf 100644
--- a/cogs/search.py
+++ b/cogs/search.py
@@ -22,10 +22,10 @@ class Search(commands.Cog):
22 """Autocomplete function for file search.""" 22 """Autocomplete function for file search."""
23 query = ctx.value.lower() if ctx.value else "" 23 query = ctx.value.lower() if ctx.value else ""
24 results = await search_utils.UniversalSearcher.search_copyparty_autocomplete(query, max_results=25) 24 results = await search_utils.UniversalSearcher.search_copyparty_autocomplete(query, max_results=25)
25 25
26 user_id = ctx.interaction.user.id 26 user_id = ctx.interaction.user.id
27 self._cached_results[user_id] = {urllib.parse.unquote(url.split('/')[-1]): url for url in results} 27 self._cached_results[user_id] = {urllib.parse.unquote(url.split('/')[-1]): url for url in results}
28 28
29 choices = [] 29 choices = []
30 for url in results[:25]: 30 for url in results[:25]:
31 filename = urllib.parse.unquote(url.split('/')[-1]) 31 filename = urllib.parse.unquote(url.split('/')[-1])
@@ -47,20 +47,20 @@ class Search(commands.Cog):
47 if not filename: 47 if not filename:
48 await ctx.reply("Please select a file from the autocomplete options.") 48 await ctx.reply("Please select a file from the autocomplete options.")
49 return 49 return
50 50
51 await ctx.defer() 51 await ctx.defer()
52 logger.info(f"Search command called by {ctx.author} for file: {filename}") 52 logger.info(f"Search command called by {ctx.author} for file: {filename}")
53 53
54 cached = self._cached_results.get(ctx.author.id) 54 cached = self._cached_results.get(ctx.author.id)
55 if not cached: 55 if not cached:
56 await ctx.send_followup("Search results expired. Please search again.") 56 await ctx.send_followup("Search results expired. Please search again.")
57 return 57 return
58 58
59 matching_url = cached.get(filename) 59 matching_url = cached.get(filename)
60 if not matching_url: 60 if not matching_url:
61 await ctx.send_followup(f"File '{filename}' not found.") 61 await ctx.send_followup(f"File '{filename}' not found.")
62 return 62 return
63 63
64 try: 64 try:
65 await ctx.send_followup(matching_url) 65 await ctx.send_followup(matching_url)
66 logger.info(f"Successfully sent URL: {matching_url}") 66 logger.info(f"Successfully sent URL: {matching_url}")