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

@@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Utility
guild = (SocketGuild)channel.Guild;
else
guild = _client.Guilds.FirstOrDefault(g => g.Name.ToUpperInvariant() == guildName.ToUpperInvariant());
if (guild == null)
if (guild is null)
return;
var ownername = guild.GetUser(guild.OwnerId);
var textchn = guild.TextChannels.Count();
@@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Utility
public async Task ChannelInfo(ITextChannel channel = null)
{
var ch = channel ?? (ITextChannel)ctx.Channel;
if (ch == null)
if (ch is null)
return;
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22);
var usercount = (await ch.GetUsersAsync().FlattenAsync().ConfigureAwait(false)).Count();
@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Utility
{
var user = usr ?? ctx.User as IGuildUser;
if (user == null)
if (user is null)
return;
var embed = new EmbedBuilder()

View File

@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Utility
//}
}
if (quote == null)
if (quote is null)
return;
var rep = new ReplacementBuilder()
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Utility
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
}
if (keywordquote == null)
if (keywordquote is null)
return;
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 " + keyword.ToLowerInvariant() + ": " +

View File

@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
ulong target;
target = meorhere == MeOrHere.Me ? ctx.User.Id : ctx.Channel.Id;
if (!await RemindInternal(target, meorhere == MeOrHere.Me || ctx.Guild == null, remindData.Time, remindData.What)
if (!await RemindInternal(target, meorhere == MeOrHere.Me || ctx.Guild is null, remindData.Time, remindData.What)
.ConfigureAwait(false))
{
await ReplyErrorLocalizedAsync("remind_too_long").ConfigureAwait(false);
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Utility
}
}
if (rem == null)
if (rem is null)
{
await ReplyErrorLocalizedAsync("reminder_not_exist").ConfigureAwait(false);
}
@@ -186,7 +186,7 @@ namespace NadekoBot.Modules.Utility
await uow.SaveChangesAsync();
}
var gTime = ctx.Guild == null
var gTime = ctx.Guild is null
? time
: TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(ctx.Guild.Id));
try

View File

@@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Utility.Services
{
await Task.Yield();
if (guild == null || string.IsNullOrWhiteSpace(input))
if (guild is null || string.IsNullOrWhiteSpace(input))
return input;
if (guild != null)

View File

@@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Utility.Services
data = JsonConvert.DeserializeObject<PatreonData>(res);
var pledgers = data.Data.Where(x => x["type"].ToString() == "pledge");
rewards.AddRange(pledgers.Select(x => JsonConvert.DeserializeObject<PatreonPledge>(x.ToString()))
.Where(x => x.attributes.declined_since == null));
.Where(x => x.attributes.declined_since is null));
if (data.Included != null)
{
users.AddRange(data.Included
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Utility.Services
var users = uow.Set<RewardedUser>();
var usr = users.FirstOrDefault(x => x.PatreonUserId == data.User.id);
if (usr == null)
if (usr is null)
{
users.Add(new RewardedUser()
{

View File

@@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Utility.Services
if (r.IsPrivate)
{
var user = _client.GetUser(r.ChannelId);
if (user == null)
if (user is null)
return;
ch = await user.GetOrCreateDMChannelAsync().ConfigureAwait(false);
}
@@ -164,7 +164,7 @@ namespace NadekoBot.Modules.Utility.Services
{
ch = _client.GetGuild(r.ServerId)?.GetTextChannel(r.ChannelId);
}
if (ch == null)
if (ch is null)
return;
await ch.EmbedAsync(new EmbedBuilder()

View File

@@ -165,7 +165,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
return;
}
while (!(current is null) && current.Value.NextTime < rep.NextTime)
while (current is not null && current.Value.NextTime < rep.NextTime)
current = current.Next;
if (current is null)

View File

@@ -239,7 +239,7 @@ namespace NadekoBot.Modules.Utility.Services
|| a.Name.ToUpperInvariant().Contains(setting.Keyword.ToUpperInvariant())
|| setting.Whitelist.Any(x => x.UserId == user.Id)));
if (!(g is null)
if (g is not null
&& setting.Enabled
&& setting.Blacklist.All(x => x.UserId != user.Id)
&& user.RoleIds.Contains(setting.FromRoleId))
@@ -247,7 +247,7 @@ namespace NadekoBot.Modules.Utility.Services
try
{
addRole = addRole ?? user.Guild.GetRole(setting.AddRoleId);
if (addRole == null)
if (addRole is null)
{
await StopStreamRole(user.Guild).ConfigureAwait(false);
Log.Warning("Stream role in server {0} no longer exists. Stopping.", setting.AddRoleId);
@@ -278,7 +278,7 @@ namespace NadekoBot.Modules.Utility.Services
try
{
addRole = addRole ?? user.Guild.GetRole(setting.AddRoleId);
if (addRole == null)
if (addRole is null)
throw new StreamRoleNotFoundException();
await user.RemoveRoleAsync(addRole).ConfigureAwait(false);
@@ -300,7 +300,7 @@ namespace NadekoBot.Modules.Utility.Services
return;
var addRole = guild.GetRole(setting.AddRoleId);
if (addRole == null)
if (addRole is null)
return;
if (setting.Enabled)

View File

@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Utility.Services
private async Task LogVerboseError(CommandInfo cmd, ITextChannel channel, string reason)
{
if (channel == null || !guildsEnabled.Contains(channel.GuildId))
if (channel is null || !guildsEnabled.Contains(channel.GuildId))
return;
try

View File

@@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Utility
{
var originUnit = _service.Units.FirstOrDefault(x => x.Triggers.Select(y => y.ToUpperInvariant()).Contains(origin.ToUpperInvariant()));
var targetUnit = _service.Units.FirstOrDefault(x => x.Triggers.Select(y => y.ToUpperInvariant()).Contains(target.ToUpperInvariant()));
if (originUnit == null || targetUnit == null)
if (originUnit is null || targetUnit is null)
{
await ReplyErrorLocalizedAsync("convert_not_found", Format.Bold(origin), Format.Bold(target)).ConfigureAwait(false);
return;

View File

@@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Utility
[RequireContext(ContextType.Guild)]
public async Task ChannelTopic([Leftover]ITextChannel channel = null)
{
if (channel == null)
if (channel is null)
channel = (ITextChannel)ctx.Channel;
var topic = channel.Topic;