diff options
author | Kobert-P <kassiaK@yahoo.de> | 2018-06-11 22:49:03 +0200 |
---|---|---|
committer | Kobert-P <kassiaK@yahoo.de> | 2018-06-11 22:49:03 +0200 |
commit | 6c0f191e6750161fe25ebe92c8db4da4ddea04f6 (patch) | |
tree | 9ac9c34e8a84abec7e6ba03448dfb67427853584 /DiscoBot/Auxiliary/CommandExtension.cs | |
parent | 8eeb66302a494853aee10c31f07752cb2c0b1655 (diff) | |
parent | 6818b66e3f2b8aea9ee58a526e667e351750c2d0 (diff) |
Merge branch 'master' of https://github.com/TrueDoctor/DiscoBot
Diffstat (limited to 'DiscoBot/Auxiliary/CommandExtension.cs')
-rw-r--r-- | DiscoBot/Auxiliary/CommandExtension.cs | 37 |
1 files changed, 37 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)); + } } } |