From a2b5b10625126b7e98643af9fe40569c9e004047 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 18 Apr 2026 00:24:50 +0200 Subject: refactor + preparing bot for public use Signed-off-by: salmonik --- cogs/search.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cogs/search.py') 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): """Autocomplete function for file search.""" query = ctx.value.lower() if ctx.value else "" results = await search_utils.UniversalSearcher.search_copyparty_autocomplete(query, max_results=25) - + user_id = ctx.interaction.user.id self._cached_results[user_id] = {urllib.parse.unquote(url.split('/')[-1]): url for url in results} - + choices = [] for url in results[:25]: filename = urllib.parse.unquote(url.split('/')[-1]) @@ -47,20 +47,20 @@ class Search(commands.Cog): if not filename: await ctx.reply("Please select a file from the autocomplete options.") return - + await ctx.defer() logger.info(f"Search command called by {ctx.author} for file: {filename}") - + cached = self._cached_results.get(ctx.author.id) if not cached: await ctx.send_followup("Search results expired. Please search again.") return - + matching_url = cached.get(filename) if not matching_url: await ctx.send_followup(f"File '{filename}' not found.") return - + try: await ctx.send_followup(matching_url) logger.info(f"Successfully sent URL: {matching_url}") -- cgit v1.2.3