From c29a8e14481b623248382ee81e94ef96f26e1271 Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Wed, 15 Feb 2023 17:09:50 -0500 Subject: [PATCH] make search results more clear --- cogs/search_service_cog.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cogs/search_service_cog.py b/cogs/search_service_cog.py index 876d2f7..5a9d43a 100644 --- a/cogs/search_service_cog.py +++ b/cogs/search_service_cog.py @@ -31,7 +31,7 @@ class SearchService(discord.Cog, name="SearchService"): self.EMBED_CUTOFF = 2000 # Make a mapping of all the country codes and their full country names: - async def paginate_embed(self, response_text): + async def paginate_embed(self, response_text, user: discord.Member): """Given a response text make embed pages and return a list of the pages. Codex makes it a codeblock in the embed""" response_text = [ @@ -44,15 +44,16 @@ class SearchService(discord.Cog, name="SearchService"): for count, chunk in enumerate(response_text, start=1): if not first: page = discord.Embed( - title=f"Page {count}", + title=f"Search Results", description=chunk, ) first = True else: page = discord.Embed( - title=f"Search Results", + title=f"Page {count}", description=chunk, ) + page.set_footer(text=f"Requested by {user.name}", icon_url=user.avatar.url) pages.append(page) return pages @@ -103,14 +104,14 @@ class SearchService(discord.Cog, name="SearchService"): ) urls = "\n".join(f"<{url}>" for url in urls) - query_response_message = f"**Query:**`\n\n{query.strip()}`\n\n**Query response:**\n\n{response.response.strip()}\n\n**Sources:**\n{urls}" + query_response_message = f"**Query:**\n\n`{query.strip()}`\n\n**Query response:**\n\n{response.response.strip()}\n\n**Sources:**\n{urls}" query_response_message = query_response_message.replace( "<|endofstatement|>", "" ) # If the response is too long, lets paginate using the discord pagination # helper - embed_pages = await self.paginate_embed(query_response_message) + embed_pages = await self.paginate_embed(query_response_message, ctx.user) paginator = pages.Paginator( pages=embed_pages, timeout=None,