mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
- 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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user