personalize results of the search feature, enfoce all searches to upload a text file
This commit is contained in:
1 parent
38f74aa8d8
commit
5c581fb47f
1 file changed
+7
-9
@@ -211,6 +211,7 @@ namespace StarsiegeBot
|
|||||||
// We're going to build a message.
|
// We're going to build a message.
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
DiscordMessageBuilder msg = new DiscordMessageBuilder();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
// We're going to search each QC for the stuff in toSearch.
|
// We're going to search each QC for the stuff in toSearch.
|
||||||
foreach (KeyValuePair<string, Quickchat> qc in quickchats)
|
foreach (KeyValuePair<string, Quickchat> qc in quickchats)
|
||||||
@@ -220,30 +221,27 @@ namespace StarsiegeBot
|
|||||||
{
|
{
|
||||||
// add it to the list!
|
// add it to the list!
|
||||||
sb.Append($"[{qc.Key}][T] {quickchats[qc.Key].text}\r\n");
|
sb.Append($"[{qc.Key}][T] {quickchats[qc.Key].text}\r\n");
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
if (qc.Value.soundFile.ToLower().Contains(toSearch.ToLower()))
|
if (qc.Value.soundFile.ToLower().Contains(toSearch.ToLower()))
|
||||||
{
|
{
|
||||||
// add it to the list!
|
// add it to the list!
|
||||||
sb.Append($"[{qc.Key}][S] {quickchats[qc.Key].text}\r\n");
|
sb.Append($"[{qc.Key}][S] {quickchats[qc.Key].text}\r\n");
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a message return it
|
// If we have a message return it
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
{
|
{
|
||||||
output = sb.ToString();
|
output = $"{ctx.Member.Mention}, there were {count} total matches for `{toSearch}`.";
|
||||||
|
MemoryStream mr = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()));
|
||||||
if (sb.Length >= 2000)
|
msg.WithFile($"{ctx.Member.DisplayName}_results.txt", mr, true);
|
||||||
{
|
|
||||||
output = "Here are your results.";
|
|
||||||
MemoryStream mr = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()));
|
|
||||||
msg.WithFile("results.txt", mr, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If message content is still nothing, report we found nothing.
|
// If message content is still nothing, report we found nothing.
|
||||||
output = "No results found.";
|
output = $"Sorry {ctx.Member.Mention}, no results were found for `{toSearch}`.";
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Content = output;
|
msg.Content = output;
|
||||||
|
|||||||
Reference in new issue
Block a user