public async Task ListPermissionsAsync() { var availablePermissions = _permissionRegistry.RegisteredPermissions .OrderBy(p => p.GetType().Name) .ThenBy(p => p.FriendlyName); var appearance = PaginatedAppearanceOptions.Default; appearance.HelpText = "These are the available bot-specific permissions. Scroll through the pages by using the reactions."; var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, this.Context.User, availablePermissions, p => p.FormatTitle(), p => p.Description, "No permissions available. This is most likely an error.", appearance ); await _interactivity.SendPrivateInteractiveMessageAndDeleteAsync ( this.Context, _feedback, paginatedEmbed, TimeSpan.FromMinutes(5) ); }
public async Task <IResult> ListPermissionsAsync() { var availablePermissions = _permissionRegistry.RegisteredPermissions .OrderBy(p => p.GetType().Name) .ThenBy(p => p.FriendlyName) .ToList(); var appearance = PaginatedAppearanceOptions.Default with { HelpText = "These are the available bot-specific permissions. " + "Scroll through the pages by using the reactions." }; var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( availablePermissions, p => p.FormatTitle(), p => p.Description, "No permissions available. This is most likely an error." ); return(await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, appearance, ct : this.CancellationToken )); }
public async Task <Result> ListOwnedRoleplaysAsync(IUser?discordUser = null) { discordUser ??= _context.User; var roleplays = await _discordRoleplays.QueryRoleplaysAsync ( q => q .Where(rp => rp.Server.DiscordID == _context.GuildID.Value) .Where(rp => rp.Owner.DiscordID == discordUser.ID) ); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( roleplays, r => r.Name, r => r.GetSummaryOrDefault(), "You don't have any roleplays." ); return((Result)await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, ct : this.CancellationToken )); }
public async Task ListAutorolesAsync() { var autoroles = new List <AutoroleConfiguration>(); foreach (var role in this.Context.Guild.Roles) { var getAutorole = await _autoroles.GetAutoroleAsync(role); if (!getAutorole.IsSuccess) { continue; } autoroles.Add(getAutorole.Entity); } var pager = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, autoroles, at => $"@{this.Context.Guild.Roles.First(r => r.Id == (ulong)at.DiscordRoleID).Name}", at => at.IsEnabled ? "Enabled" : "Disabled", "There are no autoroles configured." ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, pager, TimeSpan.FromMinutes(5) ); }
public async Task ListDossiersAsync() { var appearance = PaginatedAppearanceOptions.Default; appearance.Title = "Dossier Database"; var getDossiersResult = _dossiers.GetDossiers(); if (!getDossiersResult.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getDossiersResult.ErrorReason); return; } var dossiers = getDossiersResult.Entity; var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, this.Context.User, dossiers, d => d.Title, d => d.Summary ?? "No summary set.", "There are no dossiers available.", appearance ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, paginatedEmbed, TimeSpan.FromMinutes(5.0) ); }
public async Task <RuntimeResult> ListAvailablePatternsAsync() { var parts = Enum.GetValues(typeof(Pattern)) .Cast <Pattern>() .OrderBy(c => c); var options = new PaginatedAppearanceOptions { Color = Color.DarkPurple }; var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, parts, b => b.Humanize(), b => "\u200B", appearance: options ); await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage); return(RuntimeCommandResult.FromSuccess()); }
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> ListDossiersAsync() { var appearance = PaginatedAppearanceOptions.Default; appearance.Title = "Dossier Database"; var dossiers = await _dossiers.GetDossiersAsync(); var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, dossiers, d => d.Title, d => d.Summary, "There are no dossiers available.", appearance ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, paginatedEmbed, TimeSpan.FromMinutes(5.0) ); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> ListGrantedPermissionsAsync(IUser discordUser) { var userPermissions = await _permissions.GetApplicableUserPermissionsAsync(this.Context.Guild, discordUser); var permissions = _permissionRegistry.RegisteredPermissions .Where(r => userPermissions.Any(u => u.Permission == r.UniqueIdentifier)) .ToDictionary(p => p.UniqueIdentifier); var permissionInfos = new List <(string Title, string Description)>(); foreach (var permissionGroup in userPermissions.GroupBy(p => p.Permission)) { var permission = permissions[permissionGroup.Key]; var titleBuilder = new StringBuilder(); titleBuilder.Append(permission.FriendlyName); titleBuilder.Append(" ("); var grants = permissionGroup.Select ( up => $"{(up.IsGranted ? ":white_check_mark:" : ":no_entry_sign: ")} {up.Target.Humanize()}" ); titleBuilder.Append(grants.Humanize(",").Transform(To.SentenceCase)); titleBuilder.Append(")"); permissionInfos.Add((titleBuilder.ToString(), permission.Description)); } var appearance = PaginatedAppearanceOptions.Default; appearance.Author = discordUser; appearance.HelpText = "These are the permissions granted to the given user. Scroll through the pages by using the reactions."; var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, permissionInfos, p => p.Title, p => p.Description, "No permissions set.", appearance ); await _interactivity.SendPrivateInteractiveMessageAndDeleteAsync ( this.Context, _feedback, paginatedEmbed, TimeSpan.FromMinutes(5) ); return(RuntimeCommandResult.FromSuccess()); }
public async Task <IResult> ListGrantedPermissionsAsync(IUser discordUser) { var userPermissions = await _permissions.GetApplicableUserPermissionsAsync ( _context.GuildID.Value, discordUser.ID ); var permissions = _permissionRegistry.RegisteredPermissions .Where(r => userPermissions.Any(u => u.Permission == r.UniqueIdentifier)) .ToDictionary(p => p.UniqueIdentifier); var permissionInfos = new List <(string Title, string Description)>(); foreach (var permissionGroup in userPermissions.GroupBy(p => p.Permission)) { var permission = permissions[permissionGroup.Key]; var titleBuilder = new StringBuilder(); titleBuilder.Append(permission.FriendlyName); titleBuilder.Append(" ("); var grants = permissionGroup.Select ( up => $"{(up.IsGranted ? ":white_check_mark:" : ":no_entry_sign: ")} {up.Target.Humanize()}" ); titleBuilder.Append(grants.Humanize(",").Transform(To.SentenceCase)); titleBuilder.Append(')'); permissionInfos.Add((titleBuilder.ToString(), permission.Description)); } var appearance = PaginatedAppearanceOptions.Default with { HelpText = "These are the permissions granted to the given user. " + "Scroll through the pages by using the reactions." }; var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( permissionInfos, p => p.Title, p => p.Description, "No permissions set." ); return(await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, appearance, ct : this.CancellationToken )); }
public async Task <RuntimeResult> ListOwnedRoleplaysAsync(IGuildUser?discordUser = null) { if (discordUser is null) { var authorUser = this.Context.User; if (!(authorUser is IGuildUser guildUser)) { return(RuntimeCommandResult.FromError("The owner isn't a guild user.")); } discordUser = guildUser; } var getUserRoleplays = await _discordRoleplays.GetUserRoleplaysAsync(discordUser); if (!getUserRoleplays.IsSuccess) { return(getUserRoleplays.ToRuntimeResult()); } var roleplays = getUserRoleplays.Entity.ToList(); var appearance = PaginatedAppearanceOptions.Default; appearance.Title = "Your roleplays"; appearance.Author = discordUser; var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, roleplays, r => r.Name, r => r.Summary, "You don't have any roleplays.", appearance ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, paginatedEmbed, TimeSpan.FromMinutes(5.0) ); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> ListAvailableBodypartsAsync() { var parts = Enum.GetValues(typeof(Bodypart)) .Cast <Bodypart>() .OrderBy(b => b); var options = new PaginatedAppearanceOptions { Color = Color.DarkPurple }; var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, parts, b => b.Humanize(), b => { if (b.IsChiral()) { return("This part is available in both left and right versions."); } if (!b.IsGenderNeutral()) { return("This part is considered NSFW."); } if (b.IsComposite()) { return("This part is composed of smaller parts."); } return("This is a normal bodypart."); }, appearance: options ); await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage); return(RuntimeCommandResult.FromSuccess()); }
public async Task <Result> ListAutorolesAsync() { var autoroles = await _autoroles.GetAutorolesAsync(_context.GuildID.Value, ct : this.CancellationToken); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( autoroles, at => $"<@&{at.DiscordRoleID}>", at => at.IsEnabled ? "Enabled" : "Disabled", "There are no autoroles configured." ); return((Result)await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, ct : this.CancellationToken )); }
public async Task <Result> ListAvailableTransformationsAsync() { var availableSpecies = await _transformation.GetAvailableSpeciesAsync(); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( availableSpecies, s => $"{s.Name.Humanize(LetterCasing.Title)} ({s.Name})", s => $"{s.Description}\nWritten by {s.Author}.", "There are no species available." ); pages = pages.Select ( p => p with { Title = "Available species", Colour = Color.MediumPurple }
public async Task <Result> ListUnconfirmedUsersAsync ( [DiscordTypeHint(TypeHint.Role)] AutoroleConfiguration autorole ) { var getUsers = await _autoroles.GetUnconfirmedUsersAsync(autorole); if (!getUsers.IsSuccess) { return(Result.FromError(getUsers)); } var users = getUsers.Entity.ToList(); var getDiscordUsers = await Task.WhenAll ( users.Select(u => _guildAPI.GetGuildMemberAsync(_context.GuildID.Value, u.DiscordID)) ); var discordUsers = getDiscordUsers .Where(r => r.IsSuccess) .Select(r => r.Entity) .Where(u => u.User.HasValue) .ToList(); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( discordUsers, u => !u.Nickname.HasValue ? $"{u.User.Value.Username}#{u.User.Value.Discriminator} | {u.User.Value.ID}" : $"{u.Nickname} ({u.User.Value.Username}#{u.User.Value.Discriminator} | {u.User.Value.ID})", _ => "Not confirmed", "There are no users that haven't been confirmed for that role." ); return((Result)await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, ct : this.CancellationToken )); }
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> ListUnconfirmedUsersAsync(AutoroleConfiguration autorole) { var getUsers = await _autoroles.GetUnconfirmedUsersAsync(autorole); if (!getUsers.IsSuccess) { return(getUsers.ToRuntimeResult()); } var users = getUsers.Entity.ToList(); var discordUsers = await Task.WhenAll ( users.Select(u => this.Context.Guild.GetUserAsync((ulong)u.DiscordID)) ); // Filter out users that are no longer in the guild discordUsers = discordUsers.Where(u => !(u is null)).ToArray(); var listMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, discordUsers, u => u.Nickname is null ? $"({u.Username}#{u.Discriminator} | {u.Id})" : $"{u.Nickname} ({u.Username}#{u.Discriminator} | {u.Id})", u => "Not confirmed", "There are no users that haven't been confirmed for that role." ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, listMessage, TimeSpan.FromMinutes(5) ); return(RuntimeCommandResult.FromSuccess()); }
public async Task ListOwnedRoleplaysAsync([CanBeNull] IUser discordUser = null) { discordUser = discordUser ?? this.Context.Message.Author; var getUserResult = await _users.GetOrRegisterUserAsync(discordUser); if (!getUserResult.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getUserResult.ErrorReason); return; } var user = getUserResult.Entity; var roleplays = _roleplays.GetUserRoleplays(user, this.Context.Guild); var appearance = PaginatedAppearanceOptions.Default; appearance.Title = "Your roleplays"; appearance.Author = discordUser; var paginatedEmbed = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, this.Context.User, roleplays, r => r.Name, r => r.Summary ?? "No summary set.", "You don't have any roleplays.", appearance ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, paginatedEmbed, TimeSpan.FromMinutes(5.0) ); }
public async Task ListAvailableShadeModifiersAsync() { var parts = Enum.GetValues(typeof(ShadeModifier)) .Cast <ShadeModifier>() .OrderBy(sm => sm); var options = new PaginatedAppearanceOptions { Color = Color.DarkPurple }; var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, this.Context.User, parts, b => b.Humanize(), b => "\u200B", appearance: options ); await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage); }
public async Task ListUnconfirmedUsersAsync(AutoroleConfiguration autorole) { var getUsers = _autoroles.GetUnconfirmedUsers(autorole); if (!getUsers.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getUsers.ErrorReason); return; } var users = await getUsers.Entity.ToListAsync(); var discordUsers = await Task.WhenAll ( users.Select(u => this.Context.Guild.GetUserAsync((ulong)u.DiscordID)) ); var listMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, discordUsers, u => $"{u.Nickname} ({u.Username}#{u.Discriminator} | {u.Id})", u => "Not confirmed", "There are no users that haven't been confirmed for that role." ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, listMessage, TimeSpan.FromMinutes(5) ); }
public async Task <Result> ListServerRoleplaysAsync() { var roleplays = await _discordRoleplays.QueryRoleplaysAsync ( q => q .Where(rp => rp.Server.DiscordID == _context.GuildID.Value) .Where(rp => rp.IsPublic) ); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( roleplays, r => r.Name, r => r.GetSummaryOrDefault(), "There are no roleplays in the server that you can view." ); return((Result)await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, ct : this.CancellationToken )); }
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()); }