Fixed bugs with currency
This commit is contained in:
parent
f7ff7a5867
commit
814f7ca8b7
@ -31,7 +31,6 @@ namespace NadekoBot.Modules.Gambling
|
||||
CurrencySign = conf.CurrencySign;
|
||||
CurrencyPluralName = conf.CurrencyPluralName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
@ -68,26 +67,18 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
|
||||
[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;
|
||||
if (amount <= 0)
|
||||
return;
|
||||
bool success = 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();
|
||||
}
|
||||
var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)umsg.Author, $"Gift to {receiver.Username} ({receiver.Id}).", amount, true).ConfigureAwait(false);
|
||||
if (!success)
|
||||
{
|
||||
await channel.SendMessageAsync($"{umsg.Author.Mention} You don't have enough {Gambling.CurrencyPluralName}s.").ConfigureAwait(false);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -160,7 +151,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
var str = $"{guildUser.Mention} `You rolled {rng}.` ";
|
||||
if (rng < 67)
|
||||
{
|
||||
str += "Better luck next time.";
|
||||
str += "More luck next time.";
|
||||
}
|
||||
else if (rng < 90)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user