mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Changed all == null to is null and all !(* == null) to * is not null
This commit is contained in:
@@ -104,7 +104,7 @@ namespace NadekoBot.Core.Services
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(prefix))
|
||||
throw new ArgumentNullException(nameof(prefix));
|
||||
if (guild == null)
|
||||
if (guild is null)
|
||||
throw new ArgumentNullException(nameof(guild));
|
||||
|
||||
using (var uow = _db.GetDbContext())
|
||||
@@ -181,8 +181,8 @@ namespace NadekoBot.Core.Services
|
||||
"Channel: {2}\n\t" +
|
||||
"Message: {3}",
|
||||
usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0}
|
||||
(channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
||||
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
||||
(channel is null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
||||
(channel is null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
||||
usrMsg.Content // {3}
|
||||
);
|
||||
}
|
||||
@@ -209,8 +209,8 @@ namespace NadekoBot.Core.Services
|
||||
"Message: {3}\n\t" +
|
||||
"Error: {4}",
|
||||
usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0}
|
||||
(channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
||||
(channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
||||
(channel is null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1}
|
||||
(channel is null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2}
|
||||
usrMsg.Content,// {3}
|
||||
errorMessage
|
||||
//exec.Result.ErrorReason // {4}
|
||||
|
@@ -67,7 +67,7 @@ namespace NadekoBot.Core.Services.Common
|
||||
|
||||
byte[][] vals = Array.Empty<byte[]>();
|
||||
vals = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
if (vals.Any(x => x == null))
|
||||
if (vals.Any(x => x is null))
|
||||
vals = vals.Where(x => x != null).ToArray();
|
||||
|
||||
await _db.KeyDeleteAsync(GetKey(key)).ConfigureAwait(false);
|
||||
|
@@ -70,7 +70,7 @@ namespace NadekoBot.Core.Services
|
||||
if (!conf.SendChannelByeMessage) return;
|
||||
var channel = (await user.Guild.GetTextChannelsAsync().ConfigureAwait(false)).SingleOrDefault(c => c.Id == conf.ByeMessageChannelId);
|
||||
|
||||
if (channel == null) //maybe warn the server owner that the channel is missing
|
||||
if (channel is null) //maybe warn the server owner that the channel is missing
|
||||
return;
|
||||
|
||||
if (GroupGreets)
|
||||
|
@@ -35,7 +35,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
CultureInfo cultureInfo = null;
|
||||
try
|
||||
{
|
||||
if (x.Value == null)
|
||||
if (x.Value is null)
|
||||
return null;
|
||||
cultureInfo = new CultureInfo(x.Value);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
{
|
||||
_commandData.TryGetValue(key, out var toReturn);
|
||||
|
||||
if (toReturn == null)
|
||||
if (toReturn is null)
|
||||
return new CommandData
|
||||
{
|
||||
Cmd = key,
|
||||
|
@@ -81,7 +81,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
{
|
||||
var time = TimeSpan.FromHours(period);
|
||||
var _db = Redis.GetDatabase();
|
||||
if ((bool?)_db.StringGet($"{_redisKey}_timelyclaim_{id}") == null)
|
||||
if ((bool?)_db.StringGet($"{_redisKey}_timelyclaim_{id}") is null)
|
||||
{
|
||||
_db.StringSet($"{_redisKey}_timelyclaim_{id}", true, time);
|
||||
return null;
|
||||
@@ -104,7 +104,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
time = _db.KeyTimeToLive($"{_redisKey}_affinity_{userId}");
|
||||
if (time == null)
|
||||
if (time is null)
|
||||
{
|
||||
time = TimeSpan.FromMinutes(30);
|
||||
_db.StringSet($"{_redisKey}_affinity_{userId}", true, time);
|
||||
@@ -117,7 +117,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
time = _db.KeyTimeToLive($"{_redisKey}_divorce_{userId}");
|
||||
if (time == null)
|
||||
if (time is null)
|
||||
{
|
||||
time = TimeSpan.FromHours(6);
|
||||
_db.StringSet($"{_redisKey}_divorce_{userId}", true, time);
|
||||
@@ -182,7 +182,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
{
|
||||
var obj = await factory(param).ConfigureAwait(false);
|
||||
|
||||
if (obj == null)
|
||||
if (obj is null)
|
||||
return default(TOut);
|
||||
|
||||
await _db.StringSetAsync(key, JsonConvert.SerializeObject(obj),
|
||||
|
@@ -190,7 +190,7 @@ namespace NadekoBot.Core.Services
|
||||
JsonConvert.SerializeObject(msg),
|
||||
CommandFlags.FireAndForget);
|
||||
var p = _shardProcesses[shardId];
|
||||
if (p == null)
|
||||
if (p is null)
|
||||
return; // ignore
|
||||
_shardProcesses[shardId] = null;
|
||||
try
|
||||
@@ -204,7 +204,7 @@ namespace NadekoBot.Core.Services
|
||||
private void OnDataReceived(RedisChannel ch, RedisValue data)
|
||||
{
|
||||
var msg = JsonConvert.DeserializeObject<ShardComMessage>(data);
|
||||
if (msg == null)
|
||||
if (msg is null)
|
||||
return;
|
||||
var db = _redis.GetDatabase();
|
||||
//sets the shard state
|
||||
@@ -316,7 +316,7 @@ namespace NadekoBot.Core.Services
|
||||
for (var i = 0; i < _shardProcesses.Length; i++)
|
||||
{
|
||||
var p = _shardProcesses[i];
|
||||
if (p == null || p.HasExited)
|
||||
if (p is null || p.HasExited)
|
||||
{
|
||||
Log.Warning("Scheduling shard {0} for restart because it's process is stopped.", i);
|
||||
_shardStartQueue.Enqueue(i);
|
||||
@@ -370,7 +370,7 @@ namespace NadekoBot.Core.Services
|
||||
Log.Error(ex, "Unhandled exception in RunAsync");
|
||||
foreach (var p in _shardProcesses)
|
||||
{
|
||||
if (p == null)
|
||||
if (p is null)
|
||||
continue;
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user