.give will send dms again

This commit is contained in:
Kwoth
2022-04-27 00:36:27 +02:00
parent 0f68abcac9
commit 24a9a02cc3
4 changed files with 19 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
### Fixed ### Fixed
- Fixed `.deletexp` command - Fixed `.deletexp` command
- `.give` command should send DMs again
## [4.1.2] - 16.04.2022 ## [4.1.2] - 16.04.2022

View File

@@ -339,7 +339,7 @@ public partial class Gambling : GamblingModule<GamblingService>
return; return;
} }
if (!await _cs.TransferAsync(ctx.User.Id, receiver.Id, amount, ctx.User.ToString(), msg)) if (!await _cs.TransferAsync(_eb, ctx.User, receiver, amount, msg))
{ {
await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign)); await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
return; return;

View File

@@ -13,17 +13,26 @@ public static class CurrencyServiceExtensions
// todo transfer should be a transaction // todo transfer should be a transaction
public static async Task<bool> TransferAsync( public static async Task<bool> TransferAsync(
this ICurrencyService cs, this ICurrencyService cs,
ulong fromId, IEmbedBuilderService ebs,
ulong toId, IUser from,
IUser to,
long amount, long amount,
string fromName, string? note)
string note)
{ {
var fromWallet = await cs.GetWalletAsync(fromId); var fromWallet = await cs.GetWalletAsync(from.Id);
var toWallet = await cs.GetWalletAsync(toId); var toWallet = await cs.GetWalletAsync(to.Id);
var extra = new TxData("gift", fromName, note, fromId); var extra = new TxData("gift", from.ToString()!, note, from.Id);
return await fromWallet.Transfer(amount, toWallet, extra); if (await fromWallet.Transfer(amount, toWallet, extra))
{
await to.SendConfirmAsync(ebs,
string.IsNullOrWhiteSpace(note)
? $"Gift from {from}"
: $"Gift from {from}: {note}");
return true;
}
return false;
} }
} }

View File

@@ -8,7 +8,6 @@ public interface IWallet
public Task<bool> Take(long amount, TxData txData); public Task<bool> Take(long amount, TxData txData);
public Task Add(long amount, TxData txData); public Task Add(long amount, TxData txData);
// todo message
public async Task<bool> Transfer( public async Task<bool> Transfer(
long amount, long amount,
IWallet to, IWallet to,