Using declarations and other code reformats

This commit is contained in:
Kwoth
2021-12-26 03:22:45 +01:00
parent d18f9429c6
commit b85ba177cd
64 changed files with 2349 additions and 2736 deletions

View File

@@ -1,4 +1,5 @@
using NadekoBot.Db.Models;
using Discord;
using NadekoBot.Db.Models;
namespace NadekoBot.Extensions;
@@ -55,14 +56,12 @@ public static class IUserExtensions
public static async Task<IUserMessage> SendFileAsync(this IUser user, string filePath, string caption = null, string text = null, bool isTTS = false)
{
await using (var file = File.Open(filePath, FileMode.Open))
{
return await user.SendFileAsync(file, caption ?? "x", text, isTTS).ConfigureAwait(false);
}
await using var file = File.Open(filePath, FileMode.Open);
return await UserExtensions.SendFileAsync(user, file, caption ?? "x", text, isTTS).ConfigureAwait(false);
}
public static async Task<IUserMessage> SendFileAsync(this IUser user, Stream fileStream, string fileName, string caption = null, bool isTTS = false) =>
await user.SendFileAsync(fileStream, fileName, caption, isTTS).ConfigureAwait(false);
await UserExtensions.SendFileAsync(user, fileStream, fileName, caption, isTTS).ConfigureAwait(false);
// This method is used by everything that fetches the avatar from a user
public static Uri RealAvatarUrl(this IUser usr, ushort size = 128)

View File

@@ -49,22 +49,20 @@ public static class ProcessExtensions
if (exitCode == 0 && !string.IsNullOrEmpty(stdout))
{
using (var reader = new StringReader(stdout))
using var reader = new StringReader(stdout);
while (true)
{
while (true)
var text = reader.ReadLine();
if (text is null)
{
var text = reader.ReadLine();
if (text is null)
{
return;
}
return;
}
if (int.TryParse(text, out var id))
{
children.Add(id);
// Recursively get the children
GetAllChildIdsUnix(id, children, timeout);
}
if (int.TryParse(text, out var id))
{
children.Add(id);
// Recursively get the children
GetAllChildIdsUnix(id, children, timeout);
}
}
}