Changed all == null to is null and all !(* == null) to * is not null

This commit is contained in:
Kwoth
2021-06-19 08:24:09 +02:00
parent 81406cb46a
commit d8c7cdc7f4
125 changed files with 367 additions and 366 deletions

View File

@@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Gambling
var msg = raceMessage;
if (msg == null)
if (msg is null)
raceMessage = await ctx.Channel.SendConfirmAsync(text)
.ConfigureAwait(false);
else

View File

@@ -345,7 +345,7 @@ namespace NadekoBot.Modules.Gambling.Common.Blackjack
public Task PrintState()
{
if (StateUpdated == null)
if (StateUpdated is null)
return Task.CompletedTask;
return StateUpdated.Invoke(this);
}

View File

@@ -300,7 +300,7 @@ namespace NadekoBot.Modules.Gambling.Common
public static string GetHandValue(List<Card> cards)
{
if (handValues == null)
if (handValues is null)
InitHandValues();
foreach (var kvp in handValues.Where(x => x.Value(cards)))
{

View File

@@ -169,12 +169,12 @@ namespace NadekoBot.Modules.Gambling.Common.Events
if (_emote.Name != r.Emote.Name)
return;
var gu = (r.User.IsSpecified ? r.User.Value : null) as IGuildUser;
if (gu == null // no unknown users, as they could be bots, or alts
if (gu is null // no unknown users, as they could be bots, or alts
|| msg.Id != _msg.Id // same message
|| gu.IsBot // no bots
|| (DateTime.UtcNow - gu.CreatedAt).TotalDays <= 5 // no recently created accounts
|| (_noRecentlyJoinedServer && // if specified, no users who joined the server in the last 24h
(gu.JoinedAt == null || (DateTime.UtcNow - gu.JoinedAt.Value).TotalDays < 1))) // and no users for who we don't know when they joined
(gu.JoinedAt is null || (DateTime.UtcNow - gu.JoinedAt.Value).TotalDays < 1))) // and no users for who we don't know when they joined
{
return;
}

View File

@@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Gambling.Common.Connect4
await _locker.WaitAsync().ConfigureAwait(false);
try
{
if (_players[1] == null)
if (_players[1] is null)
{
var __ = OnGameFailedToStart?.Invoke(this);
CurrentPhase = Phase.Ended;

View File

@@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Gambling
.WithOkColor();
if (msg == null)
if (msg is null)
msg = await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
else
await msg.ModifyAsync(x => x.Embed = embed.Build()).ConfigureAwait(false);

View File

@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Gambling
if (num < 1 || num > 10)
throw new ArgumentOutOfRangeException(nameof(num));
Deck cards = guildId == null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
Deck cards = guildId is null ? new Deck() : _allDecks.GetOrAdd(ctx.Guild, (s) => new Deck());
var images = new List<Image<Rgba32>>();
var cardObjects = new List<Deck.Card>();
for (var i = 0; i < num; i++)

View File

@@ -413,7 +413,7 @@ namespace NadekoBot.Modules.Gambling
--
";
if (rdMsg == null)
if (rdMsg is null)
{
rdMsg = await ctx.Channel.EmbedAsync(embed)
.ConfigureAwait(false);

View File

@@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
SocketGuild g = _client.GetGuild(guildId);
SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;
if (ch == null)
if (ch is null)
return false;
ICurrencyEvent ce;

View File

@@ -182,7 +182,7 @@ namespace NadekoBot.Modules.Gambling.Services
private Task PotentialFlowerGeneration(IUserMessage imsg)
{
var msg = imsg as SocketUserMessage;
if (msg == null || msg.Author.IsBot)
if (msg is null || msg.Author.IsBot)
return Task.CompletedTask;
if (!(imsg.Channel is ITextChannel channel))
@@ -351,7 +351,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
// try to send the message with the currency image
var msgId = await SendPlantMessageAsync(gid, ch, user, amount, pass).ConfigureAwait(false);
if (msgId == null)
if (msgId is null)
{
// if it fails it will return null, if it returns null, refund
await _cs.AddAsync(uid, "Planted currency refund", amount, gamble: false);

View File

@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Gambling.Services
var ownerUser = uow.GetOrCreateUser(owner);
// owner has to be the owner of the waifu
if (waifu == null || waifu.ClaimerId != ownerUser.Id)
if (waifu is null || waifu.ClaimerId != ownerUser.Id)
return false;
// if waifu likes the person, gotta pay the penalty
@@ -97,7 +97,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
var waifu = uow.WaifuInfo.ByWaifuUserId(user.Id);
if (waifu == null)
if (waifu is null)
return settings.Waifu.MinPrice;
var divorces = uow.WaifuUpdates.Count(x => x.Old != null &&
@@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
w = uow.WaifuInfo.ByWaifuUserId(target.Id);
isAffinity = (w?.Affinity?.UserId == user.Id);
if (w == null)
if (w is null)
{
var claimer = uow.GetOrCreateUser(user);
var waifu = uow.GetOrCreateUser(target);
@@ -257,14 +257,14 @@ namespace NadekoBot.Modules.Gambling.Services
using (var uow = _db.GetDbContext())
{
var w = uow.WaifuInfo.ByWaifuUserId(user.Id);
var newAff = target == null ? null : uow.GetOrCreateUser(target);
var newAff = target is null ? null : uow.GetOrCreateUser(target);
if (w?.Affinity?.UserId == target?.Id)
{
}
else if (!_cache.TryAddAffinityCooldown(user.Id, out remaining))
{
}
else if (w == null)
else if (w is null)
{
var thisUser = uow.GetOrCreateUser(user);
uow.WaifuInfo.Add(new WaifuInfo()
@@ -330,7 +330,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
w = uow.WaifuInfo.ByWaifuUserId(targetId);
var now = DateTime.UtcNow;
if (w?.Claimer == null || w.Claimer.UserId != user.Id)
if (w?.Claimer is null || w.Claimer.UserId != user.Id)
result = DivorceResult.NotYourWife;
else if (!_cache.TryAddDivorceCooldown(user.Id, out remaining))
{
@@ -383,7 +383,7 @@ namespace NadekoBot.Modules.Gambling.Services
var w = uow.WaifuInfo.ByWaifuUserId(giftedWaifu.Id,
set => set.Include(x => x.Items)
.Include(x => x.Claimer));
if (w == null)
if (w is null)
{
uow.WaifuInfo.Add(w = new WaifuInfo()
{

View File

@@ -104,7 +104,7 @@ namespace NadekoBot.Modules.Gambling
uow.SaveChanges();
}
if (entry == null)
if (entry is null)
{
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
return;
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Gambling
var guser = (IGuildUser)ctx.User;
var role = ctx.Guild.GetRole(entry.RoleId);
if (role == null)
if (role is null)
{
await ReplyErrorLocalizedAsync("shop_role_not_found").ConfigureAwait(false);
return;
@@ -306,7 +306,7 @@ namespace NadekoBot.Modules.Gambling
}
}
}
if (entry == null)
if (entry is null)
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
else if (!rightType)
await ReplyErrorLocalizedAsync("shop_item_wrong_type").ConfigureAwait(false);
@@ -341,7 +341,7 @@ namespace NadekoBot.Modules.Gambling
}
}
if (removed == null)
if (removed is null)
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
else
await ctx.Channel.EmbedAsync(EntryToEmbed(removed)

View File

@@ -187,11 +187,11 @@ namespace NadekoBot.Modules.Gambling
}
return;
}
if (u == null)
if (u is null)
{
await ReplyConfirmLocalizedAsync("waifu_affinity_reset");
}
else if (oldAff == null)
else if (oldAff is null)
{
await ReplyConfirmLocalizedAsync("waifu_affinity_set", Format.Bold(u.ToString()));
}
@@ -240,7 +240,7 @@ namespace NadekoBot.Modules.Gambling
[Priority(1)]
public Task WaifuInfo([Leftover]IUser target = null)
{
if (target == null)
if (target is null)
target = ctx.User;
return InternalWaifuInfo(target.Id, target.ToString());