mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Changed all == null to is null and all !(* == null) to * is not null
This commit is contained in:
@@ -23,7 +23,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
_clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
private bool AdminInGuildOrOwnerInDm() => (ctx.Guild == null && _creds.IsOwner(ctx.User))
|
||||
private bool AdminInGuildOrOwnerInDm() => (ctx.Guild is null && _creds.IsOwner(ctx.User))
|
||||
|| (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@@ -56,7 +56,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
if (string.IsNullOrWhiteSpace(message) || id < 0)
|
||||
return;
|
||||
|
||||
if ((channel == null && !_creds.IsOwner(ctx.User)) || (channel != null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||
if ((channel is null && !_creds.IsOwner(ctx.User)) || (channel != null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("insuff_perms").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -87,7 +87,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
|
||||
var customReactions = _service.GetCustomReactionsFor(ctx.Guild?.Id);
|
||||
|
||||
if (customReactions == null || !customReactions.Any())
|
||||
if (customReactions is null || !customReactions.Any())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("no_found").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -139,7 +139,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
{
|
||||
var found = _service.GetCustomReaction(ctx.Guild?.Id, (int)id);
|
||||
|
||||
if (found == null)
|
||||
if (found is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("no_found_id").ConfigureAwait(false);
|
||||
return;
|
||||
|
@@ -37,7 +37,7 @@ namespace NadekoBot.Modules.CustomReactions.Extensions
|
||||
|
||||
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Length))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
||||
|
||||
if (img?.Source == null)
|
||||
if (img?.Source is null)
|
||||
return "";
|
||||
|
||||
return " " + img.Source.Replace("b.", ".", StringComparison.InvariantCulture) + " ";
|
||||
|
@@ -237,7 +237,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
using var uow = _db.GetDbContext();
|
||||
var cr = uow.CustomReactions.GetById(id);
|
||||
|
||||
if (cr == null || cr.GuildId != guildId)
|
||||
if (cr is null || cr.GuildId != guildId)
|
||||
return null;
|
||||
|
||||
// disable allowtarget if message had target, but it was removed from it
|
||||
@@ -268,7 +268,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
if (toDelete is null)
|
||||
return null;
|
||||
|
||||
if ((toDelete.IsGlobal() && guildId == null) || (guildId == toDelete.GuildId))
|
||||
if ((toDelete.IsGlobal() && guildId is null) || (guildId == toDelete.GuildId))
|
||||
{
|
||||
uow.CustomReactions.Remove(toDelete);
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -309,7 +309,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
if (_newGuildReactions.TryGetValue(channel.Guild.Id, out var reactions) && reactions.Length > 0)
|
||||
{
|
||||
var cr = MatchCustomReactions(content, reactions);
|
||||
if (!(cr is null))
|
||||
if (cr is not null)
|
||||
return cr;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
return null;
|
||||
|
||||
var cancelled = result.FirstOrDefault(x => x.Response == "-");
|
||||
if (!(cancelled is null))
|
||||
if (cancelled is not null)
|
||||
return cancelled;
|
||||
|
||||
return result[_rng.Next(0, result.Count)];
|
||||
@@ -551,7 +551,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
lock (_gcrWriteLock)
|
||||
{
|
||||
var cr = Array.Find(_globalReactions, item => item.Id == id);
|
||||
if (!(cr is null))
|
||||
if (cr is not null)
|
||||
{
|
||||
return _pubSub.Pub(_gcrDeletedkey, cr.Id);
|
||||
}
|
||||
@@ -629,7 +629,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
var cr = uow.CustomReactions.GetById(id);
|
||||
if (cr == null || cr.GuildId != guildId)
|
||||
if (cr is null || cr.GuildId != guildId)
|
||||
return null;
|
||||
|
||||
return cr;
|
||||
|
Reference in New Issue
Block a user