diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d1be55b..0c0592e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. ### Fixed - Fixed `.deletexp` command +- `.give` command should send DMs again ## [4.1.2] - 16.04.2022 diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index f6be45831..da5997998 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -339,7 +339,7 @@ public partial class Gambling : GamblingModule 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)); return; diff --git a/src/NadekoBot/Services/Currency/CurrencyServiceExtensions.cs b/src/NadekoBot/Services/Currency/CurrencyServiceExtensions.cs index a5972ddbd..e9009c613 100644 --- a/src/NadekoBot/Services/Currency/CurrencyServiceExtensions.cs +++ b/src/NadekoBot/Services/Currency/CurrencyServiceExtensions.cs @@ -13,17 +13,26 @@ public static class CurrencyServiceExtensions // todo transfer should be a transaction public static async Task TransferAsync( this ICurrencyService cs, - ulong fromId, - ulong toId, + IEmbedBuilderService ebs, + IUser from, + IUser to, long amount, - string fromName, - string note) + string? note) { - var fromWallet = await cs.GetWalletAsync(fromId); - var toWallet = await cs.GetWalletAsync(toId); + var fromWallet = await cs.GetWalletAsync(from.Id); + 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; } } \ No newline at end of file diff --git a/src/NadekoBot/Services/Currency/IWallet.cs b/src/NadekoBot/Services/Currency/IWallet.cs index bbf33c919..6cbe4d980 100644 --- a/src/NadekoBot/Services/Currency/IWallet.cs +++ b/src/NadekoBot/Services/Currency/IWallet.cs @@ -8,7 +8,6 @@ public interface IWallet public Task Take(long amount, TxData txData); public Task Add(long amount, TxData txData); - // todo message public async Task Transfer( long amount, IWallet to,