mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule
This commit is contained in:
@@ -66,7 +66,7 @@ public sealed class NunchiGame : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
_killTimer = new(async state =>
|
||||
_killTimer = new(async _ =>
|
||||
{
|
||||
await _locker.WaitAsync();
|
||||
try
|
||||
@@ -151,7 +151,7 @@ public sealed class NunchiGame : IDisposable
|
||||
_killTimer.Change(_killTimeout, _killTimeout);
|
||||
CurrentNumber = new NadekoRandom().Next(0, 100); // reset the counter
|
||||
_passed.Clear(); // reset all users who passed (new round starts)
|
||||
if (failure != null)
|
||||
if (failure is not null)
|
||||
_participants.Remove(failure.Value); // remove the dude who failed from the list of players
|
||||
|
||||
var __ = OnRoundEnded?.Invoke(this, failure);
|
||||
|
@@ -140,14 +140,14 @@ public class TicTacToe
|
||||
return;
|
||||
|
||||
_phase = Phase.Ended;
|
||||
if (_users[1] != null)
|
||||
if (_users[1] is not null)
|
||||
{
|
||||
_winner = _users[_curUserIndex ^= 1];
|
||||
var del = _previousMessage?.DeleteAsync();
|
||||
try
|
||||
{
|
||||
await _channel.EmbedAsync(GetEmbed(GetText(strs.ttt_time_expired)));
|
||||
if (del != null)
|
||||
if (del is not null)
|
||||
await del;
|
||||
}
|
||||
catch { }
|
||||
@@ -266,7 +266,7 @@ public class TicTacToe
|
||||
|
||||
try
|
||||
{
|
||||
if (del2 != null) await del2;
|
||||
if (del2 is not null) await del2;
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
@@ -220,7 +220,7 @@ public class TriviaGame
|
||||
&& CurrentQuestion.IsAnswerCorrect(umsg.Content)
|
||||
&& !_triviaCancelSource.IsCancellationRequested)
|
||||
{
|
||||
Users.AddOrUpdate(guildUser, 1, (gu, old) => ++old);
|
||||
Users.AddOrUpdate(guildUser, 1, (_, old) => ++old);
|
||||
guess = true;
|
||||
}
|
||||
}
|
||||
|
@@ -71,7 +71,7 @@ public partial class Games
|
||||
|
||||
public IEmbedBuilder GetStats(Poll poll, string title)
|
||||
{
|
||||
var results = poll.Votes.GroupBy(kvp => kvp.VoteIndex).ToDictionary(x => x.Key, x => x.Sum(kvp => 1));
|
||||
var results = poll.Votes.GroupBy(kvp => kvp.VoteIndex).ToDictionary(x => x.Key, x => x.Sum(_ => 1));
|
||||
|
||||
var totalVotesCast = results.Sum(x => x.Value);
|
||||
|
||||
|
@@ -41,7 +41,7 @@ public class ChatterBotService : IEarlyBehavior
|
||||
|
||||
ChatterBotGuilds = new(bot.AllGuildConfigs.Where(gc => gc.CleverbotEnabled)
|
||||
.ToDictionary(gc => gc.GuildId,
|
||||
gc => new Lazy<IChatterBotSession>(() => CreateSession(), true)));
|
||||
_ => new Lazy<IChatterBotSession>(() => CreateSession(), true)));
|
||||
}
|
||||
|
||||
public IChatterBotSession CreateSession()
|
||||
|
@@ -27,7 +27,7 @@ public partial class Games
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
|
||||
var game = _service.RunningContests.GetOrAdd(ctx.Guild.Id,
|
||||
id => new(_games, _client, channel, Prefix, options, _eb));
|
||||
_ => new(_games, _client, channel, Prefix, options, _eb));
|
||||
|
||||
if (game.IsActive)
|
||||
await SendErrorAsync($"Contest already running in {game.Channel.Mention} channel.");
|
||||
|
@@ -39,7 +39,7 @@ public partial class Games
|
||||
_service.TicTacToeGames.Add(channel.Id, game);
|
||||
await ReplyConfirmLocalizedAsync(strs.ttt_created);
|
||||
|
||||
game.OnEnded += g =>
|
||||
game.OnEnded += _ =>
|
||||
{
|
||||
_service.TicTacToeGames.Remove(channel.Id);
|
||||
_sem.Dispose();
|
||||
|
Reference in New Issue
Block a user