mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Fixed a nullref message when the bot is loading medusae. Added support for multiple embeds in features which support custom embeds in the form of
{plainText:text-here, embeds: [embedObject, embedObject, embedObject]}
			
			
This commit is contained in:
		@@ -23,6 +23,11 @@ public static class Extensions
 | 
			
		||||
                x.Embed = set.GetEmbed().Build();
 | 
			
		||||
                x.Content = set.PlainText?.SanitizeMentions() ?? "";
 | 
			
		||||
            }),
 | 
			
		||||
            SmartEmbedTextArray set => msg.ModifyAsync(x =>
 | 
			
		||||
            {
 | 
			
		||||
                x.Embeds = set.GetEmbedBuilders().Map(eb => eb.Build());
 | 
			
		||||
                x.Content = set.PlainText?.SanitizeMentions() ?? "";
 | 
			
		||||
            }),
 | 
			
		||||
            SmartPlainText spt => msg.ModifyAsync(x =>
 | 
			
		||||
            {
 | 
			
		||||
                x.Content = spt.Text.SanitizeMentions();
 | 
			
		||||
@@ -116,8 +121,7 @@ public static class Extensions
 | 
			
		||||
            args = strings.GetCommandStrings(cmd.Summary, culture).Args;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return Array.ConvertAll(args,
 | 
			
		||||
            arg => GetFullUsage(cmd.Name, arg, prefix));
 | 
			
		||||
        return args.Map(arg => GetFullUsage(cmd.Name, arg, prefix));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static string GetFullUsage(string commandName, string args, string prefix)
 | 
			
		||||
 
 | 
			
		||||
@@ -16,19 +16,22 @@ public static class MessageChannelExtensions
 | 
			
		||||
    public static Task<IUserMessage> SendAsync(
 | 
			
		||||
        this IMessageChannel channel,
 | 
			
		||||
        string? plainText,
 | 
			
		||||
        Embed? embed,
 | 
			
		||||
        Embed? embed = null,
 | 
			
		||||
        Embed[]? embeds = null,
 | 
			
		||||
        bool sanitizeAll = false)
 | 
			
		||||
    {
 | 
			
		||||
        plainText = sanitizeAll ? plainText?.SanitizeAllMentions() ?? "" : plainText?.SanitizeMentions() ?? "";
 | 
			
		||||
 | 
			
		||||
        return channel.SendMessageAsync(plainText, embed: embed);
 | 
			
		||||
        return channel.SendMessageAsync(plainText, embed: embed, embeds: embeds);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Task<IUserMessage> SendAsync(this IMessageChannel channel, SmartText text, bool sanitizeAll = false)
 | 
			
		||||
        => text switch
 | 
			
		||||
        {
 | 
			
		||||
            SmartEmbedText set => channel.SendAsync(set.PlainText, set.GetEmbed().Build(), sanitizeAll),
 | 
			
		||||
            SmartPlainText st => channel.SendAsync(st.Text, null, sanitizeAll),
 | 
			
		||||
            SmartEmbedText set => channel.SendAsync(set.PlainText, set.GetEmbed().Build(), sanitizeAll: sanitizeAll),
 | 
			
		||||
            SmartPlainText st => channel.SendAsync(st.Text, null, sanitizeAll: sanitizeAll),
 | 
			
		||||
            SmartEmbedTextArray arr => channel.SendAsync(arr.PlainText,
 | 
			
		||||
                embeds: arr.GetEmbedBuilders().Map(e => e.Build())),
 | 
			
		||||
            _ => throw new ArgumentOutOfRangeException(nameof(text))
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user