/// <summary>
        /// Replies with a paginated embed result showing the complete list of cryptocurrencies.
        /// </summary>
        /// <param name="cryptoCurrenciesList">The list of cryptocurrency codes.</param>
        private async Task SendDeferredCryptoCurrencyListAsync(List <CryptoCodeResponse> cryptoCurrenciesList)
        {
            string currencyCommand = GetType().GetMethod(nameof(GetCryptoCurrenciesAsync)).GetCustomAttributes(true).OfType <SlashCommandAttribute>().First().Name;

            EmbedBuilder[] embeds = CryptoService.CreateCryptoListEmbedAsync(cryptoCurrenciesList, currencyCommand).ToArray();
            await SendDeferredPaginatedEmbedAsync(embeds);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Replies with a paginated embed message containing all the cryptocurrency codes.
        /// </summary>
        /// <param name="currenciesList">The collection of valid currency codes.</param>
        /// <param name="isSubSearch">Indicates wether the <paramref name="currenciesList"/> is a subset of the initial collection.</param>
        /// <param name="typingState">Optional. The active typing state.</param>
        private async Task SendCryptoCurrencyListAsync(List <CryptoCodeResponse> currenciesList, bool isSubSearch = false, string title = null, string description = null, IDisposable typingState = null)
        {
            string commandPrefix   = Configuration["commandPrefix"];
            int    replyTimeout    = Convert.ToInt32(Configuration["interactiveMessageReplyTimeout"]);
            string currencyCommand = GetType().GetMethod(nameof(GetCryptoRatesAsync)).GetCustomAttributes(true).OfType <CommandAttribute>().First().Text;

            List <EmbedBuilder> embeds = CryptoService.CreateCryptoListEmbedAsync(currenciesList, currencyCommand, isSubSearch, Context.User.Username, title, description);

            await SendPagedReplyAsync(embeds, true);

            if (typingState != null)
            {
                typingState.Dispose();
            }

            SocketMessage userResponse = await NextMessageAsync(timeout : TimeSpan.FromSeconds(replyTimeout));

            if (userResponse != null)
            {
                string currencyCode = Format.Sanitize(userResponse.Content).RemoveFormat(true).Trim();
                if (!currencyCode.StartsWith(commandPrefix))
                {
                    using (Context.Channel.EnterTypingState())
                    {
                        await SendCryptoCurrencyValueAsync(currencyCode, currenciesList, !isSubSearch, typingState);
                    }
                }
            }
        }