mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
- .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:
@@ -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
|
||||
|
Reference in New Issue
Block a user