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

@@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Administration
public async Task Slowmode(StoopidTime time = null)
{
var seconds = (int?)time?.Time.TotalSeconds ?? 0;
if (!(time is null) && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6)))
if (time is not null && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6)))
return;
@@ -305,13 +305,13 @@ namespace NadekoBot.Modules.Administration
var msg = await channel.GetMessageAsync(messageId).ConfigureAwait(false);
if (msg == null)
if (msg is null)
{
await ReplyErrorLocalizedAsync("msg_not_found").ConfigureAwait(false);
return;
}
if (time == null)
if (time is null)
{
await msg.DeleteAsync().ConfigureAwait(false);
}

View File

@@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Administration
return;
}
var existing = roles.Select(rid => ctx.Guild.GetRole(rid)).Where(r => !(r is null))
var existing = roles.Select(rid => ctx.Guild.GetRole(rid)).Where(r => r is not null)
.ToList();
if (existing.Count != roles.Count)

View File

@@ -19,14 +19,14 @@ namespace NadekoBot.Modules.Administration
{
var vch = ((IGuildUser)ctx.User).VoiceChannel;
if (vch == null)
if (vch is null)
{
await ReplyErrorLocalizedAsync("not_in_voice").ConfigureAwait(false);
return;
}
var id = _service.ToggleGameVoiceChannel(ctx.Guild.Id, vch.Id);
if (id == null)
if (id is null)
{
await ReplyConfirmLocalizedAsync("gvc_disabled").ConfigureAwait(false);
}

View File

@@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Administration
var str = string.Join("\n", Enum.GetNames(typeof(LogType))
.Select(x =>
{
var val = l == null ? null : GetLogProperty(l, Enum.Parse<LogType>(x));
var val = l is null ? null : GetLogProperty(l, Enum.Parse<LogType>(x));
if (val != null)
return $"{Format.Bold(x)} <#{val}>";
return Format.Bold(x);

View File

@@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Administration
var msg = await _service.RemovePlayingAsync(index).ConfigureAwait(false);
if (msg == null)
if (msg is null)
return;
await ReplyConfirmLocalizedAsync("reprm", msg).ConfigureAwait(false);

View File

@@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Administration
return;
}
if (!(punishTime is null))
if (punishTime is not null)
{
if (!_service.IsDurationAllowed(action))
{
@@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Administration
var stats = await _service.StartAntiRaidAsync(ctx.Guild.Id, userThreshold, seconds,
action, time).ConfigureAwait(false);
if (stats == null)
if (stats is null)
{
return;
}
@@ -185,7 +185,7 @@ namespace NadekoBot.Modules.Administration
if (messageCount < 2 || messageCount > 10)
return;
if (!(timeData is null))
if (timeData is not null)
{
if (!_service.IsDurationAllowed(action))
{
@@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Administration
.WithValue(GetAntiRaidString(raid).TrimTo(1024))
.WithIsInline(true));
if (!(alt is null))
if (alt is not null)
embed.AddField("Anti-Alt", GetAntiAltString(alt), true);
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);

View File

@@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Administration
var msgs = await ((SocketTextChannel)ctx.Channel).GetMessagesAsync().FlattenAsync().ConfigureAwait(false);
var prev = (IUserMessage)msgs.FirstOrDefault(x => x is IUserMessage && x.Id != ctx.Message.Id);
if (prev == null)
if (prev is null)
return;
if (input.Length % 2 != 0)
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Administration
{
var ch = g.GetTextChannel(rr.ChannelId);
IUserMessage msg = null;
if (!(ch is null))
if (ch is not null)
{
msg = await ch.GetMessageAsync(rr.MessageId).ConfigureAwait(false) as IUserMessage;
}

View File

@@ -138,7 +138,7 @@ namespace NadekoBot.Modules.Administration
rolesStr.AppendLine("\t\t\t\t ⟪" + groupNameText + "⟫");
foreach (var (Model, Role) in kvp.AsEnumerable())
{
if (Role == null)
if (Role is null)
{
continue;
}

View File

@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Administration
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithTitle(GetText("scadd"))
.AddField(efb => efb.WithName(GetText("server"))
.WithValue(cmd.GuildId == null ? $"-" : $"{cmd.GuildName}/{cmd.GuildId}").WithIsInline(true))
.WithValue(cmd.GuildId is null ? $"-" : $"{cmd.GuildName}/{cmd.GuildId}").WithIsInline(true))
.AddField(efb => efb.WithName(GetText("channel"))
.WithValue($"{cmd.ChannelName}/{cmd.ChannelId}").WithIsInline(true))
.AddField(efb => efb.WithName(GetText("command_text"))
@@ -419,7 +419,7 @@ namespace NadekoBot.Modules.Administration
.WithDefault(Context)
.Build();
await _bot.SetGameAsync(game == null ? game : rep.Replace(game), type).ConfigureAwait(false);
await _bot.SetGameAsync(game is null ? game : rep.Replace(game), type).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync("set_game").ConfigureAwait(false);
}
@@ -448,7 +448,7 @@ namespace NadekoBot.Modules.Administration
var sid = ulong.Parse(ids[0]);
var server = _client.Guilds.FirstOrDefault(s => s.Id == sid);
if (server == null)
if (server is null)
return;
var rep = new ReplacementBuilder()
@@ -459,7 +459,7 @@ namespace NadekoBot.Modules.Administration
{
var cid = ulong.Parse(ids[1].Substring(2));
var ch = server.TextChannels.FirstOrDefault(c => c.Id == cid);
if (ch == null)
if (ch is null)
{
return;
}
@@ -477,7 +477,7 @@ namespace NadekoBot.Modules.Administration
{
var uid = ulong.Parse(ids[1].Substring(2));
var user = server.Users.FirstOrDefault(u => u.Id == uid);
if (user == null)
if (user is null)
{
return;
}

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;

View File

@@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Administration
try { tz = TimeZoneInfo.FindSystemTimeZoneById(id); } catch { tz = null; }
if (tz == null)
if (tz is null)
{
await ReplyErrorLocalizedAsync("timezone_not_found").ConfigureAwait(false);
return;

View File

@@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Administration
var embed = new EmbedBuilder()
.WithOkColor();
if (punishment == null)
if (punishment is null)
{
embed.WithDescription(GetText("user_warned",
Format.Bold(user.ToString())));
@@ -430,7 +430,7 @@ namespace NadekoBot.Modules.Administration
{
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
var embed = _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
if (!(embed is null))
if (embed is not null)
{
var userChannel = await guildUser.GetOrCreateDMChannelAsync();
await userChannel.EmbedAsync(embed);
@@ -497,7 +497,7 @@ namespace NadekoBot.Modules.Administration
{
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), msg);
var embed = _service.GetBanUserDmEmbed(Context, user, defaultMessage, msg, null);
if (!(embed is null))
if (embed is not null)
{
var userChannel = await user.GetOrCreateDMChannelAsync();
await userChannel.EmbedAsync(embed);
@@ -613,7 +613,7 @@ namespace NadekoBot.Modules.Administration
var bun = bans.FirstOrDefault(x => x.User.ToString().ToLowerInvariant() == user.ToLowerInvariant());
if (bun == null)
if (bun is null)
{
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
return;
@@ -632,7 +632,7 @@ namespace NadekoBot.Modules.Administration
var bun = bans.FirstOrDefault(x => x.User.Id == userId);
if (bun == null)
if (bun is null)
{
await ReplyErrorLocalizedAsync("user_not_found").ConfigureAwait(false);
return;

View File

@@ -41,13 +41,13 @@ namespace NadekoBot.Modules.Administration
var vc = user.VoiceChannel;
if (vc == null || vc.GuildId != user.GuildId)
if (vc is null || vc.GuildId != user.GuildId)
{
await ReplyErrorLocalizedAsync("must_be_in_voice").ConfigureAwait(false);
return;
}
if (role == null)
if (role is null)
{
if (_service.RemoveVcRole(ctx.Guild.Id, vc.Id))
{