Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule

This commit is contained in:
Kwoth
2022-01-01 08:44:51 +01:00
parent f81f9fadd3
commit 9b4eb21321
91 changed files with 1591 additions and 224 deletions

View File

@@ -139,7 +139,7 @@ public static class Extensions
public static IEmbedBuilder AddPaginatedFooter(this IEmbedBuilder embed, int curPage, int? lastPage)
{
if (lastPage != null)
if (lastPage is not null)
return embed.WithFooter($"{curPage + 1} / {lastPage + 1}");
return embed.WithFooter(curPage.ToString());
}
@@ -196,7 +196,7 @@ public static class Extensions
Task.Run(async () =>
{
await Task.Delay(seconds * 1000);
if (logService != null) logService.AddDeleteIgnore(msg.Id);
if (logService is not null) logService.AddDeleteIgnore(msg.Id);
try { await msg.DeleteAsync(); }
catch { }
@@ -206,7 +206,7 @@ public static class Extensions
public static ModuleInfo GetTopLevelModule(this ModuleInfo module)
{
while (module.Parent != null) module = module.Parent;
while (module.Parent is not null) module = module.Parent;
return module;
}
@@ -269,7 +269,7 @@ public static class Extensions
}
public static IEnumerable<IRole> GetRoles(this IGuildUser user)
=> user.RoleIds.Select(r => user.Guild.GetRole(r)).Where(r => r != null);
=> user.RoleIds.Select(r => user.Guild.GetRole(r)).Where(r => r is not null);
public static bool IsImage(this HttpResponseMessage msg)
=> IsImage(msg, out _);

View File

@@ -40,7 +40,7 @@ public static class MessageChannelExtensions
{
var embed = eb.Create().WithErrorColor().WithDescription(error).WithTitle(title);
if (url != null && Uri.IsWellFormedUriString(url, UriKind.Absolute))
if (url is not null && Uri.IsWellFormedUriString(url, UriKind.Absolute))
embed.WithUrl(url);
if (!string.IsNullOrWhiteSpace(footer))
@@ -65,7 +65,7 @@ public static class MessageChannelExtensions
{
var embed = eb.Create().WithOkColor().WithDescription(text).WithTitle(title);
if (url != null && Uri.IsWellFormedUriString(url, UriKind.Absolute))
if (url is not null && Uri.IsWellFormedUriString(url, UriKind.Absolute))
embed.WithUrl(url);
if (!string.IsNullOrWhiteSpace(footer))

View File

@@ -1,5 +1,6 @@
using NadekoBot.Common.Yml;
using Newtonsoft.Json;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.RegularExpressions;