示例#1
0
        public async Task Process(SocketUserMessage msg)
        {
            var em = new EmbedBuilder()
                     .WithAuthor("Make A Donation", Globals.Client.CurrentUser.GetAvatarUrl())
                     .WithDescription("Would you like to make a donation?\n" +
                                      "If you would like to remain anonymous, please omit the payment id")
                     .WithColor(Color.Gold)
                     .WithThumbnailUrl(Globals.Client.CurrentUser.GetAvatarUrl());

            foreach (var j in ((FusionBotConfig)(Globals.Bot.Config)).AccountJson.Accounts)
            {
                if (j.Display)
                {
                    em.AddField($"__{j.Name}__", $"{j.Address}\n\u200b");
                }
            }

            em.AddField("Payment ID", $"{IdEncrypter.Encrypt(msg.Author.Id, 0)}\n\u200b");

            await DiscordResponse.Reply(msg, privateOnly : true, embed : em.Build());
        }
示例#2
0
        public async Task Process(SocketUserMessage msg)
        {
            FusionBotConfig                 cfg       = ((FusionBotConfig)Globals.Bot.Config);
            GetAccountsResponseData         balances  = null;
            List <GetTransfersResponseData> transfers = new List <GetTransfersResponseData>();

            await new GetAccounts(null, (GetAccountsResponseData result) =>
            {
                balances = result;
            }, null, cfg.WalletHost, cfg.DonationWalletPort).RunAsync();

            if (balances == null)
            {
                await DiscordResponse.Reply(msg, text : "Sorry. Couldn't retrieve the donation account balances...");

                return;
            }

            foreach (var a in cfg.AccountJson.Accounts)
            {
                if (!a.Display)
                {
                    transfers.Add(null);
                    continue;
                }

                await new GetTransfers(new GetTransfersRequestData
                {
                    AccountIndex = (uint)a.Index
                }, (GetTransfersResponseData result) =>
                {
                    transfers.Add(result);
                }, null, cfg.WalletHost, cfg.DonationWalletPort).RunAsync();
            }

            if (cfg.AccountJson.Accounts.Length != transfers.Count)
            {
                await DiscordResponse.Reply(msg, text : "Sorry. Couldn't retrieve the donation account balances...");

                return;
            }

            EmbedBuilder eb = new EmbedBuilder()
                              .WithAuthor("Donation Account Balances", Globals.Client.CurrentUser.GetAvatarUrl())
                              .WithDescription("These are the balances of all the donation accounts")
                              .WithColor(Color.Red)
                              .WithThumbnailUrl(Globals.Client.CurrentUser.GetAvatarUrl());

            for (int i = 0; i < cfg.AccountJson.Accounts.Length; i++)
            {
                var a = cfg.AccountJson[i];

                if (!a.Display)
                {
                    continue;
                }

                var bb = balances.Accounts[i].UnlockedBalance;
                var tt = transfers[i];

                StringBuilder sb = new StringBuilder();

                foreach (var t in tt.Incoming.OrderByDescending(x => x.Height).Take(5))
                {
                    ulong s, r;
                    IdEncrypter.Decrypt(t.PaymentId, out s, out r);
                    sb.AppendLine($"{s.ToMention()}: {t.Amount.FromAtomicUnits()}");
                }

                sb.AppendLine("\u200b");

                ulong outTotal = 0;
                foreach (var o in tt.Outgoing)
                {
                    outTotal += o.Amount;
                }

                eb.AddField($"{a.Name}: {bb.FromAtomicUnits()} XNV ({outTotal.FromAtomicUnits()} out)", sb.ToString());
            }

            await DiscordResponse.Reply(msg, embed : eb.Build());
        }