Fixed bugs with currency
This commit is contained in:
		| @@ -31,7 +31,6 @@ namespace NadekoBot.Modules.Gambling | |||||||
|                 CurrencySign = conf.CurrencySign; |                 CurrencySign = conf.CurrencySign; | ||||||
|                 CurrencyPluralName = conf.CurrencyPluralName; |                 CurrencyPluralName = conf.CurrencyPluralName; | ||||||
|             } |             } | ||||||
|              |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] |         [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] | ||||||
| @@ -68,26 +67,18 @@ namespace NadekoBot.Modules.Gambling | |||||||
|          |          | ||||||
|         [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] |         [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] | ||||||
|         [RequireContext(ContextType.Guild)] |         [RequireContext(ContextType.Guild)] | ||||||
|         public async Task Give(IUserMessage umsg, long amount, [Remainder] IUser receiver) |         public async Task Give(IUserMessage umsg, long amount, [Remainder] IGuildUser receiver) | ||||||
|         { |         { | ||||||
|             var channel = (ITextChannel)umsg.Channel; |             var channel = (ITextChannel)umsg.Channel; | ||||||
|             if (amount <= 0) |             if (amount <= 0) | ||||||
|                 return; |                 return; | ||||||
|             bool success = false; |             var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)umsg.Author, $"Gift to {receiver.Username} ({receiver.Id}).", amount, true).ConfigureAwait(false); | ||||||
|             using (var uow = DbHandler.UnitOfWork()) |  | ||||||
|             { |  | ||||||
|                 success = uow.Currency.TryUpdateState(umsg.Author.Id, amount); |  | ||||||
|                 if(success) |  | ||||||
|                     uow.Currency.TryUpdateState(umsg.Author.Id, amount); |  | ||||||
|  |  | ||||||
|                 await uow.CompleteAsync(); |  | ||||||
|             } |  | ||||||
|             if (!success) |             if (!success) | ||||||
|             { |             { | ||||||
|                 await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}s.").ConfigureAwait(false); |                 await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}s.").ConfigureAwait(false); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |             await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {umsg.Author.Username} ({umsg.Author.Id}).", amount, true).ConfigureAwait(false); | ||||||
|             await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {Gambling.CurrencyPluralName}s to {receiver.Mention}!").ConfigureAwait(false); |             await channel.SendMessageAsync($"{umsg.Author.Mention} successfully sent {amount} {Gambling.CurrencyPluralName}s to {receiver.Mention}!").ConfigureAwait(false); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -160,7 +151,7 @@ namespace NadekoBot.Modules.Gambling | |||||||
|             var str = $"{guildUser.Mention} `You rolled {rng}.` "; |             var str = $"{guildUser.Mention} `You rolled {rng}.` "; | ||||||
|             if (rng < 67) |             if (rng < 67) | ||||||
|             { |             { | ||||||
|                 str += "Better luck next time."; |                 str += "More luck next time."; | ||||||
|             } |             } | ||||||
|             else if (rng < 90) |             else if (rng < 90) | ||||||
|             { |             { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user