Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DiscordBot/Modules/TipModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public async Task ListTips(params string[] keywords)
if (!IsAuthorized(user))
return;

int floodCount = 20;

List<Tip> tips = null;
if (keywords?.Length > 0)
{
Expand All @@ -159,11 +161,27 @@ public async Task ListTips(params string[] keywords)
await ReplyAsync("No tips for the keywords provided were found.").DeleteAfterSeconds(5);
return;
}
if (tips.Count >= floodCount)
{
await ReplyAsync($"Total of {tips.Count} tips found for the keywords provided; refine your search.").DeleteAfterSeconds(5);
return;
}
}
else
{
tips = TipService.GetAllTips().OrderBy(t => t.Id).ToList();
if (tips.Count >= floodCount)
{
var terms = new HashSet<string>();
foreach (var tip in tips)
foreach (var term in tip.Keywords)
terms.Add(term);
var termList = string.Join("`, `", terms.OrderBy(k => k));
await ReplyAsync($"Total of {tips.Count} tips found, add one or more keywords to narrow the search.\n`{termList}`");
return;
}
}

int chunkCount = 10;
int chunkTime = 1500;
bool first = true;
Expand Down
Loading