public async Task GetDallarDeposit(CommandContext Context)
        {
            if (Program.DaemonClient.GetWalletAddressFromAccount(Context.User.Id.ToString(), true, out string Wallet))
            {
                DiscordEmbedBuilder EmbedBuilder = new DiscordEmbedBuilder();

                EmbedBuilder.WithTitle("Dallar Bot Depositing Help");
                EmbedBuilder.WithDescription("DallarBot is a Discord bot dedicated to allowing individual users on the server to easily tip each other in the chatbox. It generates a wallet for every Discord user, and you can withdraw into any address any time." + Environment.NewLine + Environment.NewLine +
                                             "Dallar Bot does not access anyone's wallets directly in order to protect everyone's privacy.");

                EmbedBuilder.AddField("Warning About Storage", "Dallar Bot should not be used as a long term storage for your Dallar. Dallar Bot is only accessible through Discord and if the Bot or Discord are down for any reason, you will *not* be able to access your stored Dallar.");
                EmbedBuilder.AddField("Dallar Bot Fees", $"All transactions with Dallar Bot incur a flat {Program.SettingsHandler.Dallar.Txfee} DAL fee to cover the Dallar blockchain transaction fees as well as funding and maintenance costs sent to the Dallar Bot server hoster.");
                EmbedBuilder.AddField("Blockchain Transactions", $"Dallar Bot uses the blockchain to keep track of its transactions, meaning your transactions will require 6 confirmation blocks before they are completed. This should take approximately 5 to 10 minutes under normal Dallar network conditions.");
                EmbedBuilder.AddField("Depositing", $"You can deposit Dallar into your Dallar Bot balance by sending Dallar to this address generated specifically for you: `{Wallet}`");

                EmbedBuilder.WithImageUrl($"https://api.qrserver.com/v1/create-qr-code/?data=dallar:{Wallet}&qzone=2");

                await LogHandlerService.LogUserActionAsync(Context, $"Fetched deposit info.");

                await DiscordHelpers.RespondAsDM(Context, EmbedBuilder.Build());
            }
            else
            {
                await DiscordHelpers.RespondAsDM(Context, $"{Context.User.Mention}: Failed to fetch your wallet address. Please contact an Administrator.");

                await LogHandlerService.LogUserActionAsync(Context, $"Failed to fetch deposit info.");
            }

            DiscordHelpers.DeleteNonPrivateMessage(Context);
        }
Exemple #2
0
        public async Task DefaultHelpAsync(CommandContext ctx, [Description("Optional command to provide help for.")] params string[] command)
        {
            // We have to use reflection because TopLevelCommands is marked private and we're not forking DSharpPlus
            PropertyInfo TopLevelCommandsProp   = typeof(CommandsNextExtension).GetProperty("TopLevelCommands", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo   TopLevelCommandsGetter = TopLevelCommandsProp.GetGetMethod(nonPublic: true);
            var          toplevel = ((Dictionary <string, Command>)TopLevelCommandsGetter.Invoke(ctx.CommandsNext, null)).Values.Distinct();

            // We instance our help formatter directly because we don't have access to the help formatting factory
            var helpbuilder = new HelpFormatter(ctx);

            if (command != null && command.Any())
            {
                Command cmd       = null;
                var     search_in = toplevel;
                foreach (var c in command)
                {
                    if (search_in == null)
                    {
                        cmd = null;
                        break;
                    }

                    // We don't have access to config so f**k it, case insensitive help
                    //if (ctx.Config.CaseSensitive)
                    //    cmd = search_in.FirstOrDefault(xc => xc.Name == c || (xc.Aliases != null && xc.Aliases.Contains(c)));
                    //else
                    cmd = search_in.FirstOrDefault(xc => xc.Name.ToLowerInvariant() == c.ToLowerInvariant() || (xc.Aliases != null && xc.Aliases.Select(xs => xs.ToLowerInvariant()).Contains(c.ToLowerInvariant())));

                    if (cmd == null)
                    {
                        break;
                    }

                    var cfl = await cmd.RunChecksAsync(ctx, true).ConfigureAwait(false);

                    if (cfl.Any())
                    {
                        throw new ChecksFailedException(cmd, ctx, cfl);
                    }

                    if (cmd is CommandGroup)
                    {
                        search_in = (cmd as CommandGroup).Children;
                    }
                    else
                    {
                        search_in = null;
                    }
                }

                if (cmd == null)
                {
                    throw new CommandNotFoundException(string.Join(" ", command));
                }

                helpbuilder.WithCommand(cmd);

                if (cmd is CommandGroup gx)
                {
                    var sxs = gx.Children.Where(xc => !xc.IsHidden);
                    var scs = new List <Command>();
                    foreach (var sc in sxs)
                    {
                        if (sc.ExecutionChecks == null || !sc.ExecutionChecks.Any())
                        {
                            scs.Add(sc);
                            continue;
                        }

                        var cfl = await sc.RunChecksAsync(ctx, true).ConfigureAwait(false);

                        if (!cfl.Any())
                        {
                            scs.Add(sc);
                        }
                    }

                    if (scs.Any())
                    {
                        helpbuilder.WithSubcommands(scs.OrderBy(xc => xc.Name));
                    }
                }
            }
            else
            {
                var sxs = toplevel.Where(xc => !xc.IsHidden);
                var scs = new List <Command>();
                foreach (var sc in sxs)
                {
                    if (sc.ExecutionChecks == null || !sc.ExecutionChecks.Any())
                    {
                        scs.Add(sc);
                        continue;
                    }

                    var cfl = await sc.RunChecksAsync(ctx, true).ConfigureAwait(false);

                    if (!cfl.Any())
                    {
                        scs.Add(sc);
                    }
                }

                if (scs.Any())
                {
                    helpbuilder.WithSubcommands(scs.OrderBy(xc => xc.Name));
                }
            }

            var hmsg = helpbuilder.Build();

            // The main reason for this change, allowing help to be DM'd and the original command deleted.
            DiscordHelpers.DeleteNonPrivateMessage(ctx);
            await DiscordHelpers.RespondAsDM(ctx, hmsg.Embed).ConfigureAwait(false);
        }