Esempio n. 1
0
        public async Task ShowAvailablePronounFamiliesAsync()
        {
            EmbedFieldBuilder CreatePronounField(IPronounProvider pronounProvider)
            {
                var ef = new EmbedFieldBuilder();

                ef.WithName(pronounProvider.Family);

                var value = $"{pronounProvider.GetSubjectForm()} ate {pronounProvider.GetPossessiveAdjectiveForm()} " +
                            $"pie that {pronounProvider.GetSubjectForm()} brought with " +
                            $"{pronounProvider.GetReflexiveForm()}.";

                value = value.Transform(To.SentenceCase);

                ef.WithValue($"*{value}*");

                return(ef);
            }

            var pronounProviders = _pronouns.GetAvailablePronounProviders().ToList();

            if (!pronounProviders.Any())
            {
                await _feedback.SendErrorAsync(this.Context, "There doesn't seem to be any pronouns available.");

                return;
            }

            var fields      = pronounProviders.Select(CreatePronounField);
            var description = "Each field below represents a pronoun that can be used with a character. The title of " +
                              "each field is the pronoun family that you use when selecting the pronoun, and below it" +
                              "is a short example of how it might be used.";

            var paginatedEmbedPages = PageFactory.FromFields
                                      (
                fields,
                description: description
                                      );

            var paginatedEmbed = new PaginatedEmbed(_feedback, _interactivity, this.Context.User).WithPages
                                 (
                paginatedEmbedPages.Select
                (
                    p => p.WithColor(Color.DarkPurple).WithTitle("Available pronouns")
                )
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5.0)
            );
        }
    public async Task <Result> ShowAvailablePronounFamiliesAsync()
    {
        EmbedField CreatePronounField(IPronounProvider pronounProvider)
        {
            var value = $"{pronounProvider.GetSubjectForm()} ate {pronounProvider.GetPossessiveAdjectiveForm()} " +
                        $"pie that {pronounProvider.GetSubjectForm()} brought with " +
                        $"{pronounProvider.GetReflexiveForm()}.";

            value = value.Transform(To.SentenceCase);

            return(new EmbedField(pronounProvider.Family, value));
        }

        var pronounProviders = _pronouns.GetAvailablePronounProviders().ToList();

        if (!pronounProviders.Any())
        {
            return(new UserError("There doesn't seem to be any pronouns available."));
        }

        var          fields      = pronounProviders.Select(CreatePronounField);
        const string description = "Each field below represents a pronoun that can be used with a character. The "
                                   + "title of each field is the pronoun family that you use when selecting the "
                                   + "pronoun, and below it is a short example of how it might be used.";

        var pageBase = new Embed
        {
            Colour = _feedback.Theme.Secondary,
            Title  = "Available pronouns"
        };

        var pages = PageFactory.FromFields
                    (
            fields,
            description: description,
            pageBase: pageBase
                    );

        return((Result)await _feedback.SendContextualPaginatedMessageAsync
               (
                   _context.User.ID,
                   pages,
                   ct : this.CancellationToken
               ));
    }