- Updated editorconfig rules to hopefully look a bit nicer.

- Removed configureawait(false) from everywhere as it doesnt' do anything in a console app and just makes the code look ugly
- Started using .WhenAll extension instead of Task.WhenAll to make it look nicer when chaining methods
This commit is contained in:
Kwoth
2021-12-28 21:14:26 +01:00
parent d093f7eed7
commit 723447c7d4
171 changed files with 1523 additions and 1594 deletions

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Modules.Gambling.Common;
namespace NadekoBot.Modules.Gambling.Services;
@@ -24,7 +24,7 @@ public class CurrencyRaffleService : INService
public async Task<(CurrencyRaffleGame, JoinErrorType?)> JoinOrCreateGame(ulong channelId, IUser user, long amount, bool mixed, Func<IUser, long, Task> onEnded)
{
await _locker.WaitAsync().ConfigureAwait(false);
await _locker.WaitAsync();
try
{
var newGame = false;
@@ -39,7 +39,7 @@ public class CurrencyRaffleService : INService
//remove money, and stop the game if this
// user created it and doesn't have the money
if (!await _cs.RemoveAsync(user.Id, "Currency Raffle Join", amount).ConfigureAwait(false))
if (!await _cs.RemoveAsync(user.Id, "Currency Raffle Join", amount))
{
if (newGame)
Games.Remove(channelId);
@@ -48,22 +48,22 @@ public class CurrencyRaffleService : INService
if (!crg.AddUser(user, amount))
{
await _cs.AddAsync(user.Id, "Curency Raffle Refund", amount).ConfigureAwait(false);
await _cs.AddAsync(user.Id, "Curency Raffle Refund", amount);
return (null, JoinErrorType.AlreadyJoinedOrInvalidAmount);
}
if (newGame)
{
var _t = Task.Run(async () =>
{
await Task.Delay(60000).ConfigureAwait(false);
await _locker.WaitAsync().ConfigureAwait(false);
await Task.Delay(60000);
await _locker.WaitAsync();
try
{
var winner = crg.GetWinner();
var won = crg.Users.Sum(x => x.Amount);
await _cs.AddAsync(winner.DiscordUser.Id, "Currency Raffle Win",
won).ConfigureAwait(false);
won);
Games.Remove(channelId, out _);
var oe = onEnded(winner.DiscordUser, won);
}