summaryrefslogtreecommitdiff
path: root/DiscoBot/Auxiliary
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-06-11 22:34:52 +0200
committerTrueDoctor <d-kobert@web.de>2018-06-11 22:34:52 +0200
commit25a4645a9defd2e71ac05bb529cbec5c04492f3a (patch)
tree873d492b7dcb105b2ce9303e7eade84017834e58 /DiscoBot/Auxiliary
parentaf937e7a8519ea3b06be651eb21b54132295c510 (diff)
added reply async Stringlist extension
Diffstat (limited to 'DiscoBot/Auxiliary')
-rw-r--r--DiscoBot/Auxiliary/CommandExtension.cs37
-rw-r--r--DiscoBot/Auxiliary/Extensions.cs1
2 files changed, 38 insertions, 0 deletions
diff --git a/DiscoBot/Auxiliary/CommandExtension.cs b/DiscoBot/Auxiliary/CommandExtension.cs
index 5d07f6c..8e8d7fb 100644
--- a/DiscoBot/Auxiliary/CommandExtension.cs
+++ b/DiscoBot/Auxiliary/CommandExtension.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
+ using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -43,6 +44,42 @@
messages.Where(x => x.Content.StartsWith($"#{token}\n") && x.Author.IsBot));
}
+ public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message)
+ {
+ var sb = new StringBuilder();
+ foreach (string re in message)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+ await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
+
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ await m.Context.Channel.SendMessageAsync("```xl\n" + sb + "\n```");
+ }
+
+ public static async Task ReplyAsync(this ModuleBase m, IEnumerable<string> message, TimeSpan time)
+ {
+ var sb = new StringBuilder();
+ foreach (string re in message)
+ {
+ if (sb.Length + re.Length > 1798)
+ {
+
+ await m.ReplyTimedAsync(sb.ToString(), time);
+
+ sb.Clear();
+ }
+
+ sb.AppendLine(re);
+ }
+
+ await m.ReplyTimedAsync(sb.ToString(), TimeSpan.FromSeconds(90));
+ }
}
}
diff --git a/DiscoBot/Auxiliary/Extensions.cs b/DiscoBot/Auxiliary/Extensions.cs
index a1d58fa..fad5dd8 100644
--- a/DiscoBot/Auxiliary/Extensions.cs
+++ b/DiscoBot/Auxiliary/Extensions.cs
@@ -29,4 +29,5 @@
return temp + str;
}
}
+
}