From da6ae2514b31c84e4000ce539550d4cf1a27fc8b Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:00:15 -0500 Subject: [PATCH 1/3] More flexible arguments in TipModule.cs --- DiscordBot/Modules/TipModule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index 8ad01239..8a5ec733 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -32,13 +32,14 @@ private bool IsAuthorized(IUser user) [Command("Tip")] [Summary("Find and provide pre-authored tips (images or text) by their keywords.")] /* removing [RequireModerator] for custom check */ - public async Task Tip(string keywords) + public async Task Tip(params string[] keywords) { var user = Context.Message.Author; if (!IsAuthorized(user)) return; - var tips = TipService.GetTips(keywords); + var terms = string.Join(",", keywords); + var tips = TipService.GetTips(terms); if (tips.Count == 0) { await ReplyAsync("No tips for the keywords provided were found."); From 9547ef745d474fa5736317333b7cee7148b9e840 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:15:53 -0500 Subject: [PATCH 2/3] Update TipModule.cs !listtips now takes keywords list also, and restricts the listing to those that match --- DiscordBot/Modules/TipModule.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index 8a5ec733..bb67e1eb 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -174,15 +174,29 @@ public async Task ReloadTipDatabase() [Command("ListTips")] [Summary("List available tips by their keywords.")] /* removing [RequireModerator] for custom check */ - public async Task ListTips() + public async Task ListTips(params string[] keywords) { var user = Context.Message.Author; if (!IsAuthorized(user)) return; - List tips = TipService.GetAllTips().OrderBy(t => t.Id).ToList(); + List tips = null; + if (keywords?.Length > 0) + { + var terms = string.Join(",", keywords); + tips = TipService.GetTips(terms); + if (tips.Count == 0) + { + await ReplyAsync("No tips for the keywords provided were found."); + return; + } + } + else + { + tips = TipService.GetAllTips().OrderBy(t => t.Id).ToList(); + } int chunkCount = 10; - int chunkTime = 2000; + int chunkTime = 1500; bool first = true; while (tips.Count > 0) From 98ec81419c7a2330a98bb8f9fe4ec323da736e02 Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:18:12 -0500 Subject: [PATCH 3/3] Update TipModule.cs --- DiscordBot/Modules/TipModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DiscordBot/Modules/TipModule.cs b/DiscordBot/Modules/TipModule.cs index bb67e1eb..793dd015 100644 --- a/DiscordBot/Modules/TipModule.cs +++ b/DiscordBot/Modules/TipModule.cs @@ -213,11 +213,11 @@ public async Task ListTips(params string[] keywords) int chunk = 0; while (tips.Count > 0 && chunk < chunkCount) { - string keywords = string.Join("`, `", tips[0].Keywords.OrderBy(k => k)); + string keywordlist = string.Join("`, `", tips[0].Keywords.OrderBy(k => k)); string images = String.Concat( Enumerable.Repeat(" :frame_photo:", tips[0].ImagePaths.Count).ToArray()); - builder.AddField($"ID: {tips[0].Id} {images}", $"`{keywords}`"); + builder.AddField($"ID: {tips[0].Id} {images}", $"`{keywordlist}`"); tips.RemoveAt(0); chunk++; }