mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -18,4 +18,15 @@ public static class ArrayExtensions
|
||||
newCrs[input.Length] = added;
|
||||
return newCrs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new array by applying the specified function to every element in the input array
|
||||
/// </summary>
|
||||
/// <param name="arr">Array to modify</param>
|
||||
/// <param name="f">Function to apply</param>
|
||||
/// <typeparam name="TIn">Orignal type of the elements in the array</typeparam>
|
||||
/// <typeparam name="TOut">Output type of the elements of the array</typeparam>
|
||||
/// <returns>New array with updated elements</returns>
|
||||
public static TOut[] Map<TIn, TOut>(this TIn[] arr, Func<TIn, TOut> f)
|
||||
=> Array.ConvertAll(arr, x => f(x));
|
||||
}
|
@@ -31,9 +31,7 @@ public static class Extensions
|
||||
{
|
||||
public static Regex UrlRegex = new Regex(@"^(https?|ftp)://(?<path>[^\s/$.?#].[^\s]*)$", RegexOptions.Compiled);
|
||||
|
||||
public static TOut[] Map<TIn, TOut>(this TIn[] arr, Func<TIn, TOut> f)
|
||||
=> Array.ConvertAll(arr, x => f(x));
|
||||
|
||||
|
||||
public static Task EditAsync(this IUserMessage msg, SmartText text)
|
||||
=> text switch
|
||||
{
|
||||
@@ -217,8 +215,8 @@ public static class Extensions
|
||||
reactionRemoved = _ => Task.CompletedTask;
|
||||
|
||||
var wrap = new ReactionEventWrapper(client, msg);
|
||||
wrap.OnReactionAdded += (r) => { var _ = Task.Run(() => reactionAdded(r)); };
|
||||
wrap.OnReactionRemoved += (r) => { var _ = Task.Run(() => reactionRemoved(r)); };
|
||||
wrap.OnReactionAdded += r => { var _ = Task.Run(() => reactionAdded(r)); };
|
||||
wrap.OnReactionRemoved += r => { var _ = Task.Run(() => reactionRemoved(r)); };
|
||||
return wrap;
|
||||
}
|
||||
|
||||
@@ -323,7 +321,7 @@ public static class Extensions
|
||||
}
|
||||
else
|
||||
{
|
||||
img.SaveAsPng(imageStream, new PngEncoder()
|
||||
img.SaveAsPng(imageStream, new()
|
||||
{
|
||||
ColorType = PngColorType.RgbWithAlpha,
|
||||
CompressionLevel = PngCompressionLevel.BestCompression
|
||||
|
@@ -10,7 +10,7 @@ public static class IMessageChannelExtensions
|
||||
{
|
||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "")
|
||||
=> ch.SendMessageAsync(msg, embed: embed.Build(),
|
||||
options: new RequestOptions() { RetryMode = RetryMode.AlwaysRetry });
|
||||
options: new() { RetryMode = RetryMode.AlwaysRetry });
|
||||
|
||||
// this is a huge problem, because now i don't have
|
||||
// access to embed builder service
|
||||
@@ -82,7 +82,7 @@ public static class IMessageChannelExtensions
|
||||
int currentPage, Func<int, IEmbedBuilder> pageFunc, int totalElements,
|
||||
int itemsPerPage, bool addPaginatedFooter = true)
|
||||
=> ctx.SendPaginatedConfirmAsync(currentPage,
|
||||
(x) => Task.FromResult(pageFunc(x)), totalElements, itemsPerPage, addPaginatedFooter);
|
||||
x => Task.FromResult(pageFunc(x)), totalElements, itemsPerPage, addPaginatedFooter);
|
||||
/// <summary>
|
||||
/// danny kamisama
|
||||
/// </summary>
|
||||
|
@@ -54,7 +54,7 @@ public static class IUserExtensions
|
||||
public static Uri RealAvatarUrl(this IUser usr, ushort size = 128)
|
||||
{
|
||||
return usr.AvatarId is null
|
||||
? new Uri(usr.GetDefaultAvatarUrl())
|
||||
? new(usr.GetDefaultAvatarUrl())
|
||||
: new Uri(usr.GetAvatarUrl(ImageFormat.Auto, size));
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ public static class Rgba32Extensions
|
||||
for (var i = 0; i < imgArray.Length; i++)
|
||||
{
|
||||
var frame = imgArray[i].Frames.CloneFrame(frameNumber % imgArray[i].Frames.Count);
|
||||
imgFrame.Mutate(x => x.DrawImage(frame, new Point(xOffset, 0), new GraphicsOptions()));
|
||||
imgFrame.Mutate(x => x.DrawImage(frame, new(xOffset, 0), new GraphicsOptions()));
|
||||
xOffset += imgArray[i].Bounds().Width;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user