- .say now uses new SmartText instead of CREmbed

- Added IMessageChannel extensions for sending smarttext
- Added implicit operator from string to smarttext (which just creates smartplaintext instance)
This commit is contained in:
Kwoth
2021-07-11 23:37:19 +02:00
parent 236c286278
commit 0064df8ae4
5 changed files with 87 additions and 21 deletions

View File

@@ -35,6 +35,23 @@ namespace NadekoBot.Extensions
public static TOut[] Map<TIn, TOut>(this TIn[] arr, Func<TIn, TOut> f)
=> Array.ConvertAll(arr, x => f(x));
public static Task<IUserMessage> SendAsync(this IMessageChannel channel, string plainText, Embed embed, bool sanitizeAll = false)
{
plainText = sanitizeAll
? plainText?.SanitizeAllMentions() ?? ""
: plainText?.SanitizeMentions() ?? "";
return channel.SendMessageAsync(plainText, embed: embed);
}
public static Task<IUserMessage> SendAsync(this IMessageChannel channel, IEmbedBuilderService eb, SmartText text, bool sanitizeAll = false)
=> text switch
{
SmartEmbedText set => channel.SendAsync(set.PlainText, set.GetEmbed(eb).Build(), sanitizeAll),
SmartPlainText st => channel.SendAsync(st.Text, null, sanitizeAll),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static Task<IUserMessage> EmbedAsync(this IMessageChannel channel, CREmbed crEmbed, IEmbedBuilderService eb, bool sanitizeAll = false)
{
var plainText = sanitizeAll