mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Kotz's editorconfig styles slightly modified. Target typed new usage. Brackets in expressions used for clarity.
This commit is contained in:
		@@ -20,7 +20,7 @@ namespace NadekoBot.Extensions;
 | 
			
		||||
 | 
			
		||||
public static class Extensions
 | 
			
		||||
{
 | 
			
		||||
    public static Regex UrlRegex = new Regex(@"^(https?|ftp)://(?<path>[^\s/$.?#].[^\s]*)$", RegexOptions.Compiled);
 | 
			
		||||
    public static Regex UrlRegex = new(@"^(https?|ftp)://(?<path>[^\s/$.?#].[^\s]*)$", RegexOptions.Compiled);
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    public static Task EditAsync(this IUserMessage msg, SmartText text)
 | 
			
		||||
@@ -69,7 +69,7 @@ public static class Extensions
 | 
			
		||||
 | 
			
		||||
    public static IEmote ToIEmote(this string emojiStr)
 | 
			
		||||
        => Emote.TryParse(emojiStr, out var maybeEmote)
 | 
			
		||||
            ? (IEmote)maybeEmote
 | 
			
		||||
            ? maybeEmote
 | 
			
		||||
            : new Emoji(emojiStr);
 | 
			
		||||
 | 
			
		||||
    // https://github.com/SixLabors/Samples/blob/master/ImageSharp/AvatarWithRoundedCorner/Program.cs
 | 
			
		||||
@@ -171,8 +171,7 @@ public static class Extensions
 | 
			
		||||
            return embed.WithFooter(curPage.ToString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Color ToDiscordColor(this Rgba32 color)
 | 
			
		||||
        => new Color(color.R, color.G, color.B);
 | 
			
		||||
    public static Color ToDiscordColor(this Rgba32 color) => new(color.R, color.G, color.B);
 | 
			
		||||
        
 | 
			
		||||
    public static IEmbedBuilder WithOkColor(this IEmbedBuilder eb) =>
 | 
			
		||||
        eb.WithColor(EmbedColor.Ok);
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ public static class IEnumerableExtensions
 | 
			
		||||
        var n = list.Count;
 | 
			
		||||
        while (n > 1)
 | 
			
		||||
        {
 | 
			
		||||
            var box = new byte[n / Byte.MaxValue + 1];
 | 
			
		||||
            var box = new byte[(n / Byte.MaxValue) + 1];
 | 
			
		||||
            int boxSum;
 | 
			
		||||
            do
 | 
			
		||||
            {
 | 
			
		||||
@@ -62,12 +62,11 @@ public static class IEnumerableExtensions
 | 
			
		||||
        return realElems;
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    public static ConcurrentDictionary<TKey, TValue> ToConcurrent<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> dict)
 | 
			
		||||
        => new ConcurrentDictionary<TKey, TValue>(dict);
 | 
			
		||||
    public static ConcurrentDictionary<TKey, TValue> ToConcurrent<TKey, TValue>(
 | 
			
		||||
        this IEnumerable<KeyValuePair<TKey, TValue>> dict) => new(dict);
 | 
			
		||||
 | 
			
		||||
    public static IndexedCollection<T> ToIndexed<T>(this IEnumerable<T> enumerable)
 | 
			
		||||
        where T : class, IIndexed
 | 
			
		||||
        => new IndexedCollection<T>(enumerable);
 | 
			
		||||
    public static IndexedCollection<T> ToIndexed<T>(this IEnumerable<T> enumerable) where T : class, IIndexed =>
 | 
			
		||||
        new(enumerable);
 | 
			
		||||
 | 
			
		||||
    public static Task<TData[]> WhenAll<TData>(this IEnumerable<Task<TData>> items)
 | 
			
		||||
        => Task.WhenAll(items);
 | 
			
		||||
 
 | 
			
		||||
@@ -10,14 +10,14 @@ public static class StringExtensions
 | 
			
		||||
    public static string PadBoth(this string str, int length)
 | 
			
		||||
    {
 | 
			
		||||
        var spaces = length - str.Length;
 | 
			
		||||
        var padLeft = spaces / 2 + str.Length;
 | 
			
		||||
        var padLeft = (spaces / 2) + str.Length;
 | 
			
		||||
        return str.PadLeft(padLeft).PadRight(length);
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    public static T MapJson<T>(this string str)
 | 
			
		||||
        => JsonConvert.DeserializeObject<T>(str);
 | 
			
		||||
 | 
			
		||||
    private static readonly HashSet<char> lettersAndDigits = new HashSet<char>(Enumerable.Range(48, 10)
 | 
			
		||||
    private static readonly HashSet<char> lettersAndDigits = new(Enumerable.Range(48, 10)
 | 
			
		||||
        .Concat(Enumerable.Range(65, 26))
 | 
			
		||||
        .Concat(Enumerable.Range(97, 26))
 | 
			
		||||
        .Select(x => (char)x));
 | 
			
		||||
@@ -102,7 +102,7 @@ public static class StringExtensions
 | 
			
		||||
        return ms;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static readonly Regex filterRegex = new Regex(@"discord(?:\.gg|\.io|\.me|\.li|(?:app)?\.com\/invite)\/(\w+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
 | 
			
		||||
    private static readonly Regex filterRegex = new(@"discord(?:\.gg|\.io|\.me|\.li|(?:app)?\.com\/invite)\/(\w+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
 | 
			
		||||
    public static bool IsDiscordInvite(this string str)
 | 
			
		||||
        => filterRegex.IsMatch(str);
 | 
			
		||||
 | 
			
		||||
@@ -137,7 +137,7 @@ public static class StringExtensions
 | 
			
		||||
        txt.All(c => lettersAndDigits.Contains(c));
 | 
			
		||||
 | 
			
		||||
    private static readonly Regex CodePointRegex
 | 
			
		||||
        = new Regex(@"(\\U(?<code>[a-zA-Z0-9]{8})|\\u(?<code>[a-zA-Z0-9]{4})|\\x(?<code>[a-zA-Z0-9]{2}))",
 | 
			
		||||
        = new(@"(\\U(?<code>[a-zA-Z0-9]{8})|\\u(?<code>[a-zA-Z0-9]{4})|\\x(?<code>[a-zA-Z0-9]{2}))",
 | 
			
		||||
            RegexOptions.Compiled);
 | 
			
		||||
        
 | 
			
		||||
    public static string UnescapeUnicodeCodePoints(this string input)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user