mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-11-04 16:44:28 -05:00
Changed all == null to is null and all !(* == null) to * is not null
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user