Use the new Csharp 8 features (pattern matching and using assignments) and cleanup some insignificant resparper complaints

This commit is contained in:
runebaas 2020-02-08 15:58:17 +01:00
parent 21f813d342
commit 3568b61f38
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
27 changed files with 217 additions and 250 deletions

View file

@ -46,7 +46,7 @@ namespace Geekbot.net.Commands.User
else
{
var target = await GetUser(user.Id);
target.Karma = target.Karma + 1;
target.Karma += 1;
SetUser(target);
actor.TimeOut = DateTimeOffset.Now;
@ -93,7 +93,7 @@ namespace Geekbot.net.Commands.User
else
{
var target = await GetUser(user.Id);
target.Karma = target.Karma - 1;
target.Karma -= 1;
SetUser(target);
actor.TimeOut = DateTimeOffset.Now;

View file

@ -74,7 +74,7 @@ namespace Geekbot.net.Commands.User.Ranking
return;
}
int guildMessages = 0;
var guildMessages = 0;
if (type == HighscoreTypes.messages)
{
guildMessages = _database.Messages
@ -99,7 +99,7 @@ namespace Geekbot.net.Commands.User.Ranking
: $"**{user.Key.Id}**");
replyBuilder.Append(type == HighscoreTypes.messages
? $" - {user.Value} {type} - {Math.Round((double) (100 * user.Value) / guildMessages, digits: 2)}%\n"
? $" - {user.Value} {type} - {Math.Round((double) (100 * user.Value) / guildMessages, 2)}%\n"
: $" - {user.Value} {type}\n");
highscorePlace++;

View file

@ -51,7 +51,7 @@ namespace Geekbot.net.Commands.User
var level = _levelCalc.GetLevel(messages);
var percent = Math.Round((double) (100 * messages) / guildMessages, digits: 2);
var percent = Math.Round((double) (100 * messages) / guildMessages, 2);
var cookies = _database.Cookies
?.FirstOrDefault(e => e.GuildId.Equals(Context.Guild.Id.AsLong()) && e.UserId.Equals(userInfo.Id.AsLong()))