Example #1
0
        public async Task ListServerRoleplaysAsync()
        {
            // TODO: Filter so that ones where the user has joined but are private are also included
            var roleplays = _roleplays.GetRoleplays(this.Context.Guild)
                            .Where(r => r.IsPublic);

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Available Roleplays";

            var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                 (
                _feedback,
                this.Context.User,
                roleplays,
                r => r.Name,
                r => r.Summary,
                "There are no roleplays in the server that you can view.",
                appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5.0)
            );
        }
        public async Task <RuntimeResult> ShowAutoroleAsync(AutoroleConfiguration autorole)
        {
            var paginatedEmbed = new PaginatedEmbed(_feedback, _interactivity, this.Context.User)
            {
                Appearance = PaginatedAppearanceOptions.Default
            };

            var baseEmbed = paginatedEmbed.Appearance.CreateEmbedBase()
                            .WithTitle("Autorole Configuration")
                            .WithDescription(MentionUtils.MentionRole((ulong)autorole.DiscordRoleID))
                            .AddField("Requires confirmation", autorole.RequiresConfirmation, true)
                            .AddField("Is enabled", autorole.IsEnabled, true);

            if (!autorole.Conditions.Any())
            {
                baseEmbed.AddField("Conditions", "No conditions");
                baseEmbed.Footer = null;

                await _feedback.SendEmbedAsync(this.Context.Channel, baseEmbed.Build());

                return(RuntimeCommandResult.FromSuccess());
            }

            var conditionFields = autorole.Conditions.Select
                                  (
                c => new EmbedFieldBuilder()
                .WithName($"Condition #{autorole.Conditions.IndexOf(c)} (ID {c.ID})")
                .WithValue(c.GetDescriptiveUIText())
                                  );

            var pages = PageFactory.FromFields(conditionFields, pageBase: baseEmbed);

            paginatedEmbed.WithPages(pages);

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5)
            );

            return(RuntimeCommandResult.FromSuccess());
        }
        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 <RuntimeResult> ListWarningsAsync(IGuildUser user)
        {
            var warnings = await _warnings.GetWarningsAsync(user);

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Warnings";
            appearance.Color = Color.Orange;

            var paginatedEmbed = await PaginatedEmbedFactory.PagesFromCollectionAsync
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                warnings,
                async (eb, warning) =>
            {
                eb.WithTitle($"Warning #{warning.ID} for {user.Username}:{user.Discriminator}");

                var author = await this.Context.Guild.GetUserAsync((ulong)warning.Author.DiscordID);
                eb.WithAuthor(author);

                eb.WithDescription(warning.Reason);

                eb.AddField("Created", warning.CreatedAt);

                if (warning.CreatedAt != warning.UpdatedAt)
                {
                    eb.AddField("Last Updated", warning.UpdatedAt);
                }

                if (warning.IsTemporary)
                {
                    eb.AddField("Expires On", warning.ExpiresOn);
                }

                if (!(warning.MessageID is null))
                {
                    // TODO
                }
            },
                appearance : appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5)
            );

            return(RuntimeCommandResult.FromSuccess());
        }
Example #5
0
        public async Task ListBansAsync(IGuildUser user)
        {
            var bans = _bans.GetBans(user);

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Bans";
            appearance.Color = Color.Orange;

            var paginatedEmbed = await PaginatedEmbedFactory.PagesFromCollectionAsync
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                bans,
                async (eb, ban) =>
            {
                eb.WithTitle($"Ban #{ban.ID} for {user.Username}:{user.Discriminator}");

                var author = await this.Context.Guild.GetUserAsync((ulong)ban.Author.DiscordID);
                eb.WithAuthor(author);

                eb.WithDescription(ban.Reason);

                eb.AddField("Created", ban.CreatedAt);

                if (ban.CreatedAt != ban.UpdatedAt)
                {
                    eb.AddField("Last Updated", ban.UpdatedAt);
                }

                if (ban.IsTemporary)
                {
                    eb.AddField("Expires On", ban.ExpiresOn);
                }

                if (!(ban.MessageID is null))
                {
                    // TODO
                }
            },
                appearance : appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5)
            );
        }
        public async Task <RuntimeResult> ListServerRoleplaysAsync()
        {
            var getRoleplays = await _discordRoleplays.GetRoleplaysAsync(this.Context.Guild);

            if (!getRoleplays.IsSuccess)
            {
                return(getRoleplays.ToRuntimeResult());
            }

            var roleplays = getRoleplays.Entity.Where(r => r.IsPublic).ToList();

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Available Roleplays";

            var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                roleplays,
                r => r.Name,
                r => r.Summary,
                "There are no roleplays in the server that you can view.",
                appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5.0)
            );

            return(RuntimeCommandResult.FromSuccess());
        }
Example #7
0
        public async Task <RuntimeResult> ListNotesAsync(IGuildUser user)
        {
            var notes = await _notes.GetNotesAsync(user);

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Notes";
            appearance.Color = Color.Gold;

            var paginatedEmbed = await PaginatedEmbedFactory.PagesFromCollectionAsync
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                notes,
                async (eb, note) =>
            {
                eb.WithTitle($"Note #{note.ID} for {user.Username}:{user.Discriminator}");

                var author = await this.Context.Guild.GetUserAsync((ulong)note.Author.DiscordID);
                eb.WithAuthor(author);

                eb.WithDescription(note.Content);

                eb.AddField("Created", note.CreatedAt);

                if (note.CreatedAt != note.UpdatedAt)
                {
                    eb.AddField("Last Updated", note.UpdatedAt);
                }
            },
                appearance : appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5)
            );

            return(RuntimeCommandResult.FromSuccess());
        }
        public async Task <RuntimeResult> ListAvailableTransformationsAsync()
        {
            var availableSpecies = await _transformation.GetAvailableSpeciesAsync();

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Available species";

            var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                availableSpecies,
                s => $"{s.Name.Humanize(LetterCasing.Title)} ({s.Name})",
                s => $"{s.Description}\nWritten by {s.Author}.",
                "There are no species available.",
                appearance
                                 );

            if (availableSpecies.Any())
            {
                paginatedEmbed.WithPages
                (
                    paginatedEmbed.Pages.Select
                    (
                        p => p.WithDescription("Use the name inside the parens when transforming body parts.")
                    )
                );
            }

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5.0)
            );

            return(RuntimeCommandResult.FromSuccess());
        }
        public async Task <RuntimeResult> ListBansAsync()
        {
            var bans = await _bans.GetBansAsync(this.Context.Guild);

            var appearance = PaginatedAppearanceOptions.Default;

            appearance.Title = "Bans";
            appearance.Color = Color.Orange;

            var paginatedEmbed = await PaginatedEmbedFactory.PagesFromCollectionAsync
                                 (
                _feedback,
                _interactivity,
                this.Context.User,
                bans,
                async (eb, ban) =>
            {
                IUser?bannedUser = null;
                if (this.Context.Client is DiscordSocketClient socketClient)
                {
                    bannedUser = await socketClient.Rest.GetUserAsync((ulong)ban.User.DiscordID);
                }

                if (bannedUser is null)
                {
                    eb.WithTitle($"Ban #{ban.ID} for user with ID {ban.User.DiscordID}");
                }
                else
                {
                    eb.WithTitle($"Ban #{ban.ID} for {bannedUser.Username}:{bannedUser.Discriminator}");
                }

                var author = await this.Context.Guild.GetUserAsync((ulong)ban.Author.DiscordID);
                eb.WithAuthor(author);

                eb.WithDescription(ban.Reason);

                eb.AddField("Created", ban.CreatedAt);

                if (ban.CreatedAt != ban.UpdatedAt)
                {
                    eb.AddField("Last Updated", ban.UpdatedAt);
                }

                if (ban.IsTemporary)
                {
                    eb.AddField("Expires On", ban.ExpiresOn);
                }

                if (!(ban.MessageID is null))
                {
                    // TODO
                }
            },
                appearance : appearance
                                 );

            await _interactivity.SendInteractiveMessageAndDeleteAsync
            (
                this.Context.Channel,
                paginatedEmbed,
                TimeSpan.FromMinutes(5)
            );

            return(RuntimeCommandResult.FromSuccess());
        }