mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Using declarations and other code reformats
This commit is contained in:
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user