public async Task WithDrawAsync([Summary("送り先のアドレス")] string address, [Summary("金額")] decimal amount = decimal.MinusOne, [Remainder] string comment = null) { var account = TippingManager.GetAccountName(Context.User); await TippingManager.EnsureAccountAsync(account).ConfigureAwait(false); var balance1 = decimal.Parse(await TippingManager.InvokeMethodAsync("getbalance", account, 1).ConfigureAwait(false)); var queued = TippingManager.GetCollection().Find(x => x.From == Context.User.Id).Sum(x => x.Amount); if (amount > 0 && amount < balance1 - queued) { var txid = await TippingManager.InvokeMethodAsync("sendfrom", account, address, amount == decimal.MinusOne?decimal.Parse(await TippingManager.InvokeMethodAsync("getbalance", account).ConfigureAwait(false)) : amount).ConfigureAwait(false); await ReplyAsync ( message : Context.User.Mention, embed : new EmbedBuilder() .WithTitle("出金完了") .WithDescription($"```{address}```\nに出金しました。") .WithCurrentTimestamp() .WithColor(Colors.Green) .WithFooter(EmbedManager.CurrentFooter) .WithAuthor(Context.User) .AddInlineField("金額", $"{amount:N8} ZNY") .AddInlineField("トランザクションID", $"```{txid}```") ).ConfigureAwait(false); if (TippingManager.GetIsAndroidMode(Context.User)) { await ReplyAsync($"```{txid}```"); } } }
public async Task DepositAsync([Remainder] string comment = null) { var address = await TippingManager.EnsureAccountAsync(TippingManager.GetAccountName(Context.User)).ConfigureAwait(false); await ReplyAsync ( message : Context.User.Mention, embed : new EmbedBuilder() .WithTitle("入金用アドレス") .WithDescription($"```{address}```") .WithCurrentTimestamp() .WithColor(Colors.Blue) .WithFooter(EmbedManager.CurrentFooter) .WithAuthor(Context.User) ).ConfigureAwait(false); if (TippingManager.GetIsAndroidMode(Context.User)) { await ReplyAsync($"```{address}```"); } }
public async Task SendAsync([Summary("送り先のユーザー")] IUser user, [Summary("金額")] decimal amount, [Remainder] string comment = null) { var account = TippingManager.GetAccountName(Context.User); var address = await TippingManager.EnsureAccountAsync(TippingManager.GetAccountName(user)).ConfigureAwait(false); var balance1 = decimal.Parse(await TippingManager.InvokeMethodAsync("getbalance", account, 1).ConfigureAwait(false)); var queued = TippingManager.GetCollection().Find(x => x.From == Context.User.Id).Sum(x => x.Amount); if (amount > 0 && amount < balance1 - queued) { var txid = await TippingManager.InvokeMethodAsync("sendfrom", account, address, amount).ConfigureAwait(false); await ReplyAsync ( message : Context.User.Mention, embed : new EmbedBuilder() .WithTitle("送金完了") .WithDescription($"{user.Mention} に送金しました。") .WithCurrentTimestamp() .WithColor(Colors.Green) .WithFooter(EmbedManager.CurrentFooter) .WithAuthor(Context.User) .WithThumbnailUrl(user.GetAvatarUrl()) .AddInlineField("金額", $"{amount:N8} ZNY") .AddInlineField("トランザクションID", $"```{txid}```") ).ConfigureAwait(false); if (TippingManager.GetIsAndroidMode(Context.User)) { await ReplyAsync($"```{txid}```"); } var embed = new EmbedBuilder() .WithTitle("送金通知") .WithDescription($"{Context.User.Mention} からの送金を受け取りました。") .WithCurrentTimestamp() .WithColor(Colors.Orange) .WithFooter(EmbedManager.CurrentFooter) .WithAuthor(user) .WithThumbnailUrl(Context.User.GetAvatarUrl()) .AddInlineField("金額", $"{amount:N8} ZNY") .AddInlineField("トランザクションID", $"```{txid}```"); if (!string.IsNullOrEmpty(comment)) { embed = embed.AddField("コメント", comment); } var dm = await user.GetOrCreateDMChannelAsync().ConfigureAwait(false); await dm.SendMessageAsync ( text : user.Mention, embed : embed ).ConfigureAwait(false); if (TippingManager.GetIsAndroidMode(user)) { await dm.SendMessageAsync($"```{txid}```"); } } else { await ReplyAsync ( message : Context.User.Mention, embed : new EmbedBuilder() .WithTitle("送金失敗") .WithDescription("送金に失敗しました。残高が不足している可能性があります。") .WithCurrentTimestamp() .WithColor(Colors.Red) .WithFooter(EmbedManager.CurrentFooter) .WithAuthor(Context.User) ).ConfigureAwait(false); } await RequestLogAsync(new LogMessage(LogSeverity.Verbose, "TippingModule", $"Sent {amount:N8} ZNY from {Context.User.Username}#{Context.User.Discriminator} to {user.Username}#{user.Discriminator}.")).ConfigureAwait(false); }