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

@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Administration.Services
var old = conf.DelMsgOnCmdChannels.FirstOrDefault(x => x.ChannelId == chId);
if (newState == Administration.State.Inherit)
{
if (!(old is null))
if (old is not null)
{
conf.DelMsgOnCmdChannels.Remove(old);
uow.Remove(old);

View File

@@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Services
{
var roleIds = savedRoleIds
.Select(roleId => user.Guild.GetRole(roleId))
.Where(x => !(x is null))
.Where(x => x is not null)
.ToList();
if (roleIds.Any())

View File

@@ -101,7 +101,7 @@ DELETE FROM Clubs;";
.FirstOrDefaultAsyncEF(x => x.Waifu.UserId == userId);
// if it exists, delete waifu related things
if (!(wi is null))
if (wi is not null)
{
// remove updates which have new or old as this waifu
await uow

View File

@@ -145,7 +145,7 @@ namespace NadekoBot.Modules.Administration.Services
public async Task<bool> TryBlockLate(DiscordSocketClient client, ICommandContext context, string moduleName,
CommandInfo command)
{
if (TryGetOverrides(context.Guild?.Id ?? 0, command.Name, out var perm) && !(perm is null))
if (TryGetOverrides(context.Guild?.Id ?? 0, command.Name, out var perm) && perm is not null)
{
var result = await new RequireUserPermissionAttribute((GuildPermission) perm)
.CheckPermissionsAsync(context, command, _services);

View File

@@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Administration.Services
{
//if the user is in the voice channel and that voice channel is gvc
var vc = after.VoiceChannel;
if (vc == null || !GameVoiceChannels.Contains(vc.Id))
if (vc is null || !GameVoiceChannels.Contains(vc.Id))
return;
//if the activity has changed, and is a playing activity
@@ -96,7 +96,7 @@ namespace NadekoBot.Modules.Administration.Services
var game = gUser.Activity?.Name;
if (oldState.VoiceChannel == newState.VoiceChannel ||
newState.VoiceChannel == null)
newState.VoiceChannel is null)
return;
if (!GameVoiceChannels.Contains(newState.VoiceChannel.Id) ||
@@ -123,7 +123,7 @@ namespace NadekoBot.Modules.Administration.Services
var vch = gUser.Guild.VoiceChannels
.FirstOrDefault(x => x.Name.ToLowerInvariant() == game);
if (vch == null)
if (vch is null)
return;
await Task.Delay(1000).ConfigureAwait(false);

View File

@@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Administration.Services
TimeZoneInfo tz;
try
{
if (x.TimeZoneId == null)
if (x.TimeZoneId is null)
tz = null;
else
tz = TimeZoneInfo.FindSystemTimeZoneById(x.TimeZoneId);
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Administration.Services
gc.TimeZoneId = tz?.Id;
uow.SaveChanges();
if (tz == null)
if (tz is null)
_timezones.TryRemove(guildId, out tz);
else
_timezones.AddOrUpdate(guildId, tz, (key, old) => tz);

View File

@@ -203,12 +203,12 @@ namespace NadekoBot.Modules.Administration.Services
var g = after.Guild;
if (!GuildLogSettings.TryGetValue(g.Id, out LogSetting logSetting)
|| (logSetting.UserUpdatedId == null))
|| (logSetting.UserUpdatedId is null))
return;
ITextChannel logChannel;
if ((logChannel =
await TryGetLogChannel(g, logSetting, LogType.UserUpdated).ConfigureAwait(false)) == null)
await TryGetLogChannel(g, logSetting, LogType.UserUpdated).ConfigureAwait(false)) is null)
return;
var embed = new EmbedBuilder();
@@ -262,54 +262,54 @@ namespace NadekoBot.Modules.Administration.Services
switch (type)
{
case LogType.Other:
channelId = logSetting.LogOtherId = (logSetting.LogOtherId == null ? cid : default);
channelId = logSetting.LogOtherId = (logSetting.LogOtherId is null ? cid : default);
break;
case LogType.MessageUpdated:
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId == null ? cid : default);
channelId = logSetting.MessageUpdatedId = (logSetting.MessageUpdatedId is null ? cid : default);
break;
case LogType.MessageDeleted:
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId == null ? cid : default);
channelId = logSetting.MessageDeletedId = (logSetting.MessageDeletedId is null ? cid : default);
//logSetting.DontLogBotMessageDeleted = (options == "nobot");
break;
case LogType.UserJoined:
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId == null ? cid : default);
channelId = logSetting.UserJoinedId = (logSetting.UserJoinedId is null ? cid : default);
break;
case LogType.UserLeft:
channelId = logSetting.UserLeftId = (logSetting.UserLeftId == null ? cid : default);
channelId = logSetting.UserLeftId = (logSetting.UserLeftId is null ? cid : default);
break;
case LogType.UserBanned:
channelId = logSetting.UserBannedId = (logSetting.UserBannedId == null ? cid : default);
channelId = logSetting.UserBannedId = (logSetting.UserBannedId is null ? cid : default);
break;
case LogType.UserUnbanned:
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId == null ? cid : default);
channelId = logSetting.UserUnbannedId = (logSetting.UserUnbannedId is null ? cid : default);
break;
case LogType.UserUpdated:
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId == null ? cid : default);
channelId = logSetting.UserUpdatedId = (logSetting.UserUpdatedId is null ? cid : default);
break;
case LogType.UserMuted:
channelId = logSetting.UserMutedId = (logSetting.UserMutedId == null ? cid : default);
channelId = logSetting.UserMutedId = (logSetting.UserMutedId is null ? cid : default);
break;
case LogType.ChannelCreated:
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId == null ? cid : default);
channelId = logSetting.ChannelCreatedId = (logSetting.ChannelCreatedId is null ? cid : default);
break;
case LogType.ChannelDestroyed:
channelId = logSetting.ChannelDestroyedId =
(logSetting.ChannelDestroyedId == null ? cid : default);
(logSetting.ChannelDestroyedId is null ? cid : default);
break;
case LogType.ChannelUpdated:
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId == null ? cid : default);
channelId = logSetting.ChannelUpdatedId = (logSetting.ChannelUpdatedId is null ? cid : default);
break;
case LogType.UserPresence:
channelId = logSetting.LogUserPresenceId =
(logSetting.LogUserPresenceId == null ? cid : default);
(logSetting.LogUserPresenceId is null ? cid : default);
break;
case LogType.VoicePresence:
channelId = logSetting.LogVoicePresenceId =
(logSetting.LogVoicePresenceId == null ? cid : default);
(logSetting.LogVoicePresenceId is null ? cid : default);
break;
case LogType.VoicePresenceTTS:
channelId = logSetting.LogVoicePresenceTTSId =
(logSetting.LogVoicePresenceTTSId == null ? cid : default);
(logSetting.LogVoicePresenceTTSId is null ? cid : default);
break;
}
@@ -335,12 +335,12 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.LogVoicePresenceTTSId == null))
|| (logSetting.LogVoicePresenceTTSId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTTS)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var str = "";
@@ -348,11 +348,11 @@ namespace NadekoBot.Modules.Administration.Services
{
str = GetText(logChannel.Guild, "log_vc_moved", usr.Username, beforeVch?.Name, afterVch?.Name);
}
else if (beforeVch == null)
else if (beforeVch is null)
{
str = GetText(logChannel.Guild, "log_vc_joined", usr.Username, afterVch.Name);
}
else if (afterVch == null)
else if (afterVch is null)
{
str = GetText(logChannel.Guild, "log_vc_left", usr.Username, beforeVch.Name);
}
@@ -375,12 +375,12 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.UserMutedId == null))
|| (logSetting.UserMutedId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var mutes = "";
var mutedLocalized = GetText(logChannel.Guild, "muted_sn");
@@ -419,12 +419,12 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.UserMutedId == null))
|| (logSetting.UserMutedId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var mutes = "";
@@ -471,11 +471,11 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(users.First().Guild.Id, out LogSetting logSetting)
|| (logSetting.LogOtherId == null))
|| (logSetting.LogOtherId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(users.First().Guild, logSetting, LogType.Other)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var punishment = "";
@@ -642,13 +642,13 @@ namespace NadekoBot.Modules.Administration.Services
var after = (IGuildChannel) cafter;
if (!GuildLogSettings.TryGetValue(before.Guild.Id, out LogSetting logSetting)
|| (logSetting.ChannelUpdatedId == null)
|| (logSetting.ChannelUpdatedId is null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == after.Id))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var embed = new EmbedBuilder().WithOkColor()
@@ -698,13 +698,13 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|| (logSetting.ChannelDestroyedId == null)
|| (logSetting.ChannelDestroyedId is null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == ch.Id))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
string title;
if (ch is IVoiceChannel)
@@ -738,12 +738,12 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out LogSetting logSetting)
|| (logSetting.ChannelCreatedId == null))
|| (logSetting.ChannelCreatedId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelCreated)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
string title;
if (ch is IVoiceChannel)
@@ -783,12 +783,12 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.LogVoicePresenceId == null))
|| (logSetting.LogVoicePresenceId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresence)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
string str = null;
@@ -799,14 +799,14 @@ namespace NadekoBot.Modules.Administration.Services
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
Format.Bold(beforeVch?.Name ?? ""), Format.Bold(afterVch?.Name ?? ""));
}
else if (beforeVch == null)
else if (beforeVch is null)
{
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild,
"user_vjoined",
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
Format.Bold(afterVch.Name ?? ""));
}
else if (afterVch == null)
else if (afterVch is null)
{
str = "🎙" + Format.Code(PrettyCurrentTime(usr.Guild)) + GetText(logChannel.Guild, "user_vleft",
"👤" + Format.Bold(usr.Username + "#" + usr.Discriminator),
@@ -836,16 +836,16 @@ namespace NadekoBot.Modules.Administration.Services
// {
// var guild = optGuild.GetValueOrDefault() ?? (usr as SocketGuildUser)?.Guild;
// if (guild == null)
// if (guild is null)
// return;
// if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
// || (logSetting.LogUserPresenceId == null)
// || (logSetting.LogUserPresenceId is null)
// || before.Status == after.Status)
// return;
// ITextChannel logChannel;
// if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserPresence)) == null)
// if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserPresence)) is null)
// return;
// string str = "";
// if (before.Status != after.Status)
@@ -878,12 +878,12 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.UserLeftId == null))
|| (logSetting.UserLeftId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var embed = new EmbedBuilder()
.WithOkColor()
@@ -912,12 +912,12 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting)
|| (logSetting.UserJoinedId == null))
|| (logSetting.UserJoinedId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var embed = new EmbedBuilder()
@@ -953,12 +953,12 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|| (logSetting.UserUnbannedId == null))
|| (logSetting.UserUnbannedId is null))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)
.ConfigureAwait(false)) == null)
.ConfigureAwait(false)) is null)
return;
var embed = new EmbedBuilder()
.WithOkColor()
@@ -987,7 +987,7 @@ namespace NadekoBot.Modules.Administration.Services
try
{
if (!GuildLogSettings.TryGetValue(guild.Id, out LogSetting logSetting)
|| (logSetting.UserBannedId == null))
|| (logSetting.UserBannedId is null))
return;
ITextChannel logChannel;
@@ -1024,7 +1024,7 @@ namespace NadekoBot.Modules.Administration.Services
try
{
var msg = (optMsg.HasValue ? optMsg.Value : null) as IUserMessage;
if (msg == null || msg.IsAuthor(_client))
if (msg is null || msg.IsAuthor(_client))
return;
if (_ignoreMessageIds.Contains(msg.Id))
@@ -1034,13 +1034,13 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|| (logSetting.MessageDeletedId == null)
|| (logSetting.MessageDeletedId is null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageDeleted)
.ConfigureAwait(false)) == null || logChannel.Id == msg.Id)
.ConfigureAwait(false)) is null || logChannel.Id == msg.Id)
return;
var resolvedMessage = msg.Resolve(userHandling: TagHandling.FullName);
@@ -1080,7 +1080,7 @@ namespace NadekoBot.Modules.Administration.Services
return;
var before = (optmsg.HasValue ? optmsg.Value : null) as IUserMessage;
if (before == null)
if (before is null)
return;
if (!(ch is ITextChannel channel))
@@ -1093,13 +1093,13 @@ namespace NadekoBot.Modules.Administration.Services
return;
if (!GuildLogSettings.TryGetValue(channel.Guild.Id, out LogSetting logSetting)
|| (logSetting.MessageUpdatedId == null)
|| (logSetting.MessageUpdatedId is null)
|| logSetting.IgnoredChannels.Any(ilc => ilc.ChannelId == channel.Id))
return;
ITextChannel logChannel;
if ((logChannel = await TryGetLogChannel(channel.Guild, logSetting, LogType.MessageUpdated)
.ConfigureAwait(false)) == null || logChannel.Id == after.Channel.Id)
.ConfigureAwait(false)) is null || logChannel.Id == after.Channel.Id)
return;
var embed = new EmbedBuilder()
@@ -1208,7 +1208,7 @@ namespace NadekoBot.Modules.Administration.Services
var channel = await guild.GetTextChannelAsync(id.Value).ConfigureAwait(false);
if (channel == null)
if (channel is null)
{
UnsetLogSetting(guild.Id, logChannelType);
return null;

View File

@@ -159,7 +159,7 @@ namespace NadekoBot.Modules.Administration.Services
{
MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet<ulong> muted);
if (muted == null || !muted.Contains(usr.Id))
if (muted is null || !muted.Contains(usr.Id))
return Task.CompletedTask;
var _ = Task.Run(() => MuteUser(usr, _client.CurrentUser, reason: "Sticky mute").ConfigureAwait(false));
}
@@ -259,7 +259,7 @@ namespace NadekoBot.Modules.Administration.Services
}
else if (type == MuteType.Voice)
{
if (usr == null)
if (usr is null)
return;
try
{
@@ -270,7 +270,7 @@ namespace NadekoBot.Modules.Administration.Services
}
else if (type == MuteType.Chat)
{
if (usr == null)
if (usr is null)
return;
await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild).ConfigureAwait(false)).ConfigureAwait(false);
UserUnmuted(usr, mod, MuteType.Chat, reason);
@@ -279,7 +279,7 @@ namespace NadekoBot.Modules.Administration.Services
public async Task<IRole> GetMuteRole(IGuild guild)
{
if (guild == null)
if (guild is null)
throw new ArgumentNullException(nameof(guild));
const string defaultMuteRoleName = "nadeko-mute";
@@ -287,7 +287,7 @@ namespace NadekoBot.Modules.Administration.Services
var muteRoleName = GuildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
if (muteRole == null)
if (muteRole is null)
{
//if it doesn't exist, create it

View File

@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Administration.Services
_antiSpamGuilds[gc.GuildId] = new AntiSpamStats() { AntiSpamSettings = spam };
var alt = gc.AntiAltSetting;
if (!(alt is null))
if (alt is not null)
_antiAltGuilds[gc.GuildId] = new AntiAltStats(alt);
}

View File

@@ -53,7 +53,7 @@ namespace NadekoBot.Modules.Administration.Services
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
if (conf == null)
if (conf is null)
return;
// compare emote names for backwards compatibility :facepalm:
@@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Administration.Services
var conf = confs.FirstOrDefault(x => x.MessageId == msg.Id);
if (conf == null)
if (conf is null)
return;
var reactionRole = conf.ReactionRoles.FirstOrDefault(x => x.EmoteName == reaction.Emote.Name || x.EmoteName == reaction.Emote.ToString());
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Administration.Services
if (reactionRole != null)
{
var role = gusr.Guild.GetRole(reactionRole.RoleId);
if (role == null)
if (role is null)
return;
await gusr.RemoveRoleAsync(role).ConfigureAwait(false);
}

View File

@@ -82,7 +82,7 @@ namespace NadekoBot.Modules.Administration.Services
var (autoDelete, exclusive, roles) = GetAdAndRoles(guildUser.Guild.Id);
var theRoleYouWant = roles.FirstOrDefault(r => r.RoleId == role.Id);
if (theRoleYouWant == null)
if (theRoleYouWant is null)
{
return (AssignResult.Err_Not_Assignable, autoDelete, null);
}
@@ -145,7 +145,7 @@ namespace NadekoBot.Modules.Administration.Services
if (toUpdate != null)
gc.SelfAssignableRoleGroupNames.Remove(toUpdate);
}
else if (toUpdate == null)
else if (toUpdate is null)
{
gc.SelfAssignableRoleGroupNames.Add(new GroupName
{
@@ -170,7 +170,7 @@ namespace NadekoBot.Modules.Administration.Services
{
var (autoDelete, _, roles) = GetAdAndRoles(guildUser.Guild.Id);
if (roles.FirstOrDefault(r => r.RoleId == role.Id) == null)
if (roles.FirstOrDefault(r => r.RoleId == role.Id) is null)
{
return (RemoveResult.Err_Not_Assignable, autoDelete);
}
@@ -261,7 +261,7 @@ namespace NadekoBot.Modules.Administration.Services
var roleModels = uow.SelfAssignableRoles.GetFromGuild(guild.Id);
roles = roleModels
.Select(x => (Model: x, Role: guild.GetRole(x.RoleId)));
uow.SelfAssignableRoles.RemoveRange(roles.Where(x => x.Role == null).Select(x => x.Model).ToArray());
uow.SelfAssignableRoles.RemoveRange(roles.Where(x => x.Role is null).Select(x => x.Model).ToArray());
uow.SaveChanges();
}

View File

@@ -74,7 +74,7 @@ namespace NadekoBot.Modules.Administration.Services
var server = _client.Guilds.FirstOrDefault(g => g.Id.ToString() == guildStr) ??
_client.Guilds.FirstOrDefault(g => g.Name.Trim().ToUpperInvariant() == guildStr);
if (server == null)
if (server is null)
{
return;
}
@@ -205,7 +205,7 @@ namespace NadekoBot.Modules.Administration.Services
var channels = await Task.WhenAll(_creds.OwnerIds.Select(id =>
{
var user = _client.GetUser(id);
if (user == null)
if (user is null)
return Task.FromResult<IDMChannel>(null);
return user.GetOrCreateDMChannelAsync();

View File

@@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Administration.Services
if (p != null)
{
var user = await guild.GetUserAsync(userId).ConfigureAwait(false);
if (user == null)
if (user is null)
return null;
await ApplyPunishment(guild, user, mod, p.Punishment, p.Time, p.RoleId, "Warned too many times.");
@@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Administration.Services
if (roleId is null)
return;
var role = guild.GetRole(roleId.Value);
if (!(role is null))
if (role is not null)
{
if (minutes == 0)
await user.AddRoleAsync(role).ConfigureAwait(false);
@@ -389,14 +389,14 @@ WHERE GuildId={guildId}
.AsQueryable()
.FirstOrDefault(x => x.GuildId == guildId);
if (text == null)
if (text is null)
{
if (template is null)
return;
uow.Remove(template);
}
else if (template == null)
else if (template is null)
{
uow.BanTemplates.Add(new BanTemplate()
{

View File

@@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Administration.Services
{
await Task.Yield();
var g = _client.GetGuild(gconf.GuildId);
if (g == null)
if (g is null)
return;
var infos = new ConcurrentDictionary<ulong, IRole>();
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Administration.Services
foreach (var ri in gconf.VcRoleInfos)
{
var role = g.GetRole(ri.RoleId);
if (role == null)
if (role is null)
{
missingRoles.Add(ri);
continue;
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Administration.Services
public void AddVcRole(ulong guildId, IRole role, ulong vcId)
{
if (role == null)
if (role is null)
throw new ArgumentNullException(nameof(role));
var guildVcRoles = VcRoles.GetOrAdd(guildId, new ConcurrentDictionary<ulong, IRole>());
@@ -184,7 +184,7 @@ namespace NadekoBot.Modules.Administration.Services
{
var gusr = usr as SocketGuildUser;
if (gusr == null)
if (gusr is null)
return Task.CompletedTask;
var oldVc = oldState.VoiceChannel;