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

@@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Permissions.Common
var result = perm.CheckPermission(message, commandName, moduleName);
if (result == null)
if (result is null)
{
continue;
}
@@ -55,13 +55,13 @@ namespace NadekoBot.Modules.Permissions.Common
return perm.State;
break;
case PrimaryPermissionType.Role:
if (guildUser == null)
if (guildUser is null)
break;
if (guildUser.RoleIds.Contains(perm.PrimaryTargetId))
return perm.State;
break;
case PrimaryPermissionType.Server:
if (guildUser == null)
if (guildUser is null)
break;
return perm.State;
}

View File

@@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Permissions
};
removed = config.FilterInvitesChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed == null)
if (removed is null)
{
config.FilterInvitesChannelIds.Add(match);
}
@@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Permissions
await uow.SaveChangesAsync();
}
if (removed == null)
if (removed is null)
{
_service.InviteFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync("invite_filter_channel_on").ConfigureAwait(false);
@@ -142,7 +142,7 @@ namespace NadekoBot.Modules.Permissions
};
removed = config.FilterLinksChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed == null)
if (removed is null)
{
config.FilterLinksChannelIds.Add(match);
}
@@ -153,7 +153,7 @@ namespace NadekoBot.Modules.Permissions
await uow.SaveChangesAsync();
}
if (removed == null)
if (removed is null)
{
_service.LinkFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync("link_filter_channel_on").ConfigureAwait(false);
@@ -207,7 +207,7 @@ namespace NadekoBot.Modules.Permissions
ChannelId = channel.Id
};
removed = config.FilterWordsChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed == null)
if (removed is null)
{
config.FilterWordsChannelIds.Add(match);
}
@@ -218,7 +218,7 @@ namespace NadekoBot.Modules.Permissions
await uow.SaveChangesAsync();
}
if (removed == null)
if (removed is null)
{
_service.WordFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync("word_filter_channel_on").ConfigureAwait(false);
@@ -248,7 +248,7 @@ namespace NadekoBot.Modules.Permissions
removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word);
if (removed == null)
if (removed is null)
config.FilteredWords.Add(new FilteredWord() { Word = word });
else
{
@@ -260,7 +260,7 @@ namespace NadekoBot.Modules.Permissions
var filteredWords = _service.ServerFilteredWords.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<string>());
if (removed == null)
if (removed is null)
{
filteredWords.Add(word);
await ReplyConfirmLocalizedAsync("filter_word_add", Format.Code(word)).ConfigureAwait(false);

View File

@@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Permissions
using (var uow = _db.GetDbContext())
{
var config = uow.GcWithPermissionsv2For(ctx.Guild.Id);
if (action == null) action = new PermissionAction(!config.VerbosePermissions); // New behaviour, can toggle.
if (action is null) action = new PermissionAction(!config.VerbosePermissions); // New behaviour, can toggle.
config.VerbosePermissions = action.Value;
await uow.SaveChangesAsync();
_service.UpdateCache(config);
@@ -57,11 +57,11 @@ namespace NadekoBot.Modules.Permissions
if (role != null && role == role.Guild.EveryoneRole)
return;
if (role == null)
if (role is null)
{
var cache = _service.GetCacheFor(ctx.Guild.Id);
if (!ulong.TryParse(cache.PermRole, out var roleId) ||
(role = ((SocketGuild)ctx.Guild).GetRole(roleId)) == null)
(role = ((SocketGuild)ctx.Guild).GetRole(roleId)) is null)
{
await ReplyConfirmLocalizedAsync("permrole_not_set", Format.Bold(cache.PermRole)).ConfigureAwait(false);
}

View File

@@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Permissions.Services
var toRemove = uow.Blacklist
.FirstOrDefault(bi => bi.ItemId == id && bi.Type == type);
if (!(toRemove is null))
if (toRemove is not null)
uow.Blacklist.Remove(toRemove);
uow.SaveChanges();

View File

@@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Permissions.Services
var guild = (channel as ITextChannel)?.Guild;
var usrMsg = newMsg as IUserMessage;
if (guild == null || usrMsg == null)
if (guild is null || usrMsg is null)
return Task.CompletedTask;
return RunBehavior(null, guild, usrMsg);

View File

@@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Permissions.Services
UpdateCache(config);
}
Cache.TryGetValue(guildId, out pc);
if (pc == null)
if (pc is null)
throw new Exception("Cache is null.");
}
return pc;
@@ -108,7 +108,7 @@ namespace NadekoBot.Modules.Permissions.Services
var commandName = command.Name.ToLowerInvariant();
await Task.Yield();
if (guild == null)
if (guild is null)
{
return false;
}
@@ -149,7 +149,7 @@ namespace NadekoBot.Modules.Permissions.Services
rid = 0;
string returnMsg;
IRole role;
if (string.IsNullOrWhiteSpace(permRole) || (role = guild.GetRole(rid)) == null)
if (string.IsNullOrWhiteSpace(permRole) || (role = guild.GetRole(rid)) is null)
{
returnMsg = $"You need Admin permissions in order to use permission commands.";
if (pc.Verbose)