public async Task <RuntimeResult> ListAvailableTransformationsAsync ( [OverrideTypeReader(typeof(HumanizerEnumTypeReader <Bodypart>))] Bodypart bodyPart ) { var transformations = await _transformation.GetAvailableTransformationsAsync(bodyPart); var eb = _feedback.CreateEmbedBase(); eb.WithTitle("Available transformations"); if (transformations.Count <= 0) { eb.WithDescription("There are no available transformations for this bodypart."); } else { eb.WithDescription("Use the name inside the parens when transforming body parts."); } foreach (var transformation in transformations) { var speciesName = $"{transformation.Species.Name.Humanize(LetterCasing.Title)} ({transformation.Species.Name})"; eb.AddField(speciesName, transformation.Description); } await _feedback.SendPrivateEmbedAsync(this.Context, this.Context.User, eb.Build()); return(RuntimeCommandResult.FromSuccess()); }
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 <RuntimeResult> 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, _interactivity, 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) ); return(RuntimeCommandResult.FromSuccess()); }
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> ModifyConditionAsync ( AutoroleConfiguration autorole, long conditionID, IRole role ) { var getCondition = _autoroles.GetCondition <RoleCondition> ( autorole, conditionID ); if (!getCondition.IsSuccess) { return(getCondition.ToRuntimeResult()); } var condition = getCondition.Entity; var modifyResult = await _autoroles.ModifyConditionAsync ( condition, c => { condition.RoleID = (long)role.Id; } ); if (!modifyResult.IsSuccess) { return(modifyResult.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Condition updated.")); }
public async Task <RuntimeResult> DeleteBanAsync(long banID) { var getBan = await _bans.GetBanAsync(this.Context.Guild, banID); if (!getBan.IsSuccess) { return(getBan.ToRuntimeResult()); } var ban = getBan.Entity; // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and // navigation properties can't be evaluated var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id); var notifyResult = await _logging.NotifyUserUnbannedAsync(ban, rescinder); if (!notifyResult.IsSuccess) { return(notifyResult.ToRuntimeResult()); } var deleteBan = await _bans.DeleteBanAsync(ban); if (!deleteBan.IsSuccess) { return(deleteBan.ToRuntimeResult()); } await this.Context.Guild.RemoveBanAsync((ulong)ban.User.DiscordID); return(RuntimeCommandResult.FromSuccess("Ban rescinded.")); }
public async Task <RuntimeResult> ShowKinkOverlap(IUser otherUser) { var getUserKinksResult = await _kinks.GetUserKinksAsync(this.Context.User); if (!getUserKinksResult.IsSuccess) { return(getUserKinksResult.ToRuntimeResult()); } var userKinks = getUserKinksResult.Entity; var getOtherUserKinksResult = await _kinks.GetUserKinksAsync(otherUser); if (!getOtherUserKinksResult.IsSuccess) { return(getOtherUserKinksResult.ToRuntimeResult()); } var otherUserKinks = getOtherUserKinksResult.Entity; var overlap = userKinks.Intersect(otherUserKinks, new UserKinkOverlapEqualityComparer()).ToList(); if (!overlap.Any()) { return(RuntimeCommandResult.FromSuccess("You don't overlap anywhere.")); } var kinkOverlapPages = _kinks.BuildKinkOverlapEmbeds(this.Context.User, otherUser, overlap); var paginatedMessage = new PaginatedEmbed(_feedback, _interactivity, this.Context.User) .WithPages(kinkOverlapPages); await _interactivity.SendPrivateInteractiveMessageAsync(this.Context, _feedback, paginatedMessage); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> DeleteNoteAsync(long noteID) { var getNote = await _notes.GetNoteAsync(this.Context.Guild, noteID); if (!getNote.IsSuccess) { return(getNote.ToRuntimeResult()); } var note = getNote.Entity; // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and // navigation properties can't be evaluated var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id); var notifyResult = await _logging.NotifyUserNoteRemovedAsync(note, rescinder); if (!notifyResult.IsSuccess) { return(notifyResult.ToRuntimeResult()); } var deleteNote = await _notes.DeleteNoteAsync(note); if (!deleteNote.IsSuccess) { return(deleteNote.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Note deleted.")); }
public async Task <RuntimeResult> HideAllRoleplaysAsync() { var getRoleplays = await _discordRoleplays.GetRoleplaysAsync(this.Context.Guild); if (!getRoleplays.IsSuccess) { return(getRoleplays.ToRuntimeResult()); } var roleplays = getRoleplays.Entity.ToList(); foreach (var roleplay in roleplays) { var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!getDedicatedChannelResult.IsSuccess) { continue; } var user = this.Context.User; var dedicatedChannel = getDedicatedChannelResult.Entity; await _dedicatedChannels.SetChannelVisibilityForUserAsync(dedicatedChannel, user, false); } return(RuntimeCommandResult.FromSuccess("Roleplays hidden.")); }
public async Task <RuntimeResult> AddBanAsync ( IGuildUser user, string reason, TimeSpan?expiresAfter = null ) { DateTime?expiresOn = null; if (!(expiresAfter is null)) { expiresOn = DateTime.Now.Add(expiresAfter.Value); } var addBan = await _bans.CreateBanAsync(this.Context.User, user, reason, expiresOn : expiresOn); if (!addBan.IsSuccess) { return(addBan.ToRuntimeResult()); } var ban = addBan.Entity; var notifyResult = await _logging.NotifyUserBannedAsync(ban); if (!notifyResult.IsSuccess) { return(notifyResult.ToRuntimeResult()); } await this.Context.Guild.AddBanAsync((ulong)ban.User.DiscordID, reason : reason); return(RuntimeCommandResult.FromSuccess($"User banned (ban ID {ban.ID}).")); }
public async Task <RuntimeResult> AddConditionAsync ( AutoroleConfiguration autorole, [OverrideTypeReader(typeof(UncachedMessageTypeReader <IMessage>))] IMessage message, IEmote emote ) { var condition = _autoroles.CreateConditionProxy <ReactionCondition> ( message, emote ); if (condition is null) { return(RuntimeCommandResult.FromError("Failed to create a condition object. Yikes!")); } var addCondition = await _autoroles.AddConditionAsync(autorole, condition); if (!addCondition.IsSuccess) { return(addCondition.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Condition added.")); }
public async Task <RuntimeResult> Default ( IRole discordRole, string permissionName, [OverrideTypeReader(typeof(HumanizerEnumTypeReader <PermissionTarget>))] PermissionTarget revokedTarget = PermissionTarget.Self ) { var getPermissionResult = _permissionRegistry.GetPermission(permissionName); if (!getPermissionResult.IsSuccess) { return(getPermissionResult.ToRuntimeResult()); } var permission = getPermissionResult.Entity; var revokePermissionResult = await _permissions.RevokePermissionAsync ( discordRole, permission, revokedTarget ); if (!revokePermissionResult.IsSuccess) { return(revokePermissionResult.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess ( $"{permission.FriendlyName} revoked from {MentionUtils.MentionRole(discordRole.Id)}." )); }
public async Task <RuntimeResult> StartRoleplayAsync ( [RequireEntityOwnerOrPermission(typeof(StartStopRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var startRoleplayResult = await _discordRoleplays.StartRoleplayAsync ( (ITextChannel)this.Context.Channel, roleplay ); if (!startRoleplayResult.IsSuccess) { return(startRoleplayResult.ToRuntimeResult()); } var joinedUsers = roleplay.JoinedUsers.Select ( async p => await this.Context.Client.GetUserAsync((ulong)p.User.DiscordID) ); var joinedMentions = joinedUsers.Select(async u => (await u).Mention); var channel = await this.Context.Guild.GetTextChannelAsync((ulong)roleplay.ActiveChannelID !); var participantList = (await Task.WhenAll(joinedMentions)).Humanize(); await channel.SendMessageAsync($"Calling {participantList}!"); var activationMessage = $"The roleplay \"{roleplay.Name}\" is now active in " + $"{MentionUtils.MentionChannel(channel.Id)}."; return(RuntimeCommandResult.FromSuccess(activationMessage)); }
public async Task <RuntimeResult> ViewDossierAsync(string title) { var getDossierResult = await _dossiers.GetDossierByTitleAsync(title); if (!getDossierResult.IsSuccess) { return(getDossierResult.ToRuntimeResult()); } var dossier = getDossierResult.Entity; var eb = BuildDossierEmbed(dossier); await _feedback.SendEmbedAsync(this.Context.Channel, eb); var dossierDataResult = _dossiers.GetDossierStream(dossier); if (!dossierDataResult.IsSuccess) { return(dossierDataResult.ToRuntimeResult()); } await using var dossierData = dossierDataResult.Entity; await this.Context.Channel.SendFileAsync(dossierData, $"{dossier.Title}.pdf"); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> Default ( IUser discordUser, string permissionName, [OverrideTypeReader(typeof(HumanizerEnumTypeReader <PermissionTarget>))] PermissionTarget grantedTarget = PermissionTarget.Self ) { var getPermissionResult = _permissionRegistry.GetPermission(permissionName); if (!getPermissionResult.IsSuccess) { return(getPermissionResult.ToRuntimeResult()); } var permission = getPermissionResult.Entity; var grantPermissionResult = await _permissions.GrantPermissionAsync ( this.Context.Guild, discordUser, permission, grantedTarget ); if (!grantPermissionResult.IsSuccess) { return(grantPermissionResult.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess ( $"{permission.FriendlyName} granted to {discordUser.Mention}." )); }
public async Task <RuntimeResult> SetCharacterRoleAccessAsync ( IRole discordRole, RoleAccess access ) { var getExistingRoleResult = await _characterRoles.GetCharacterRoleAsync(discordRole); if (!getExistingRoleResult.IsSuccess) { return(getExistingRoleResult.ToRuntimeResult()); } var setRoleAccessResult = await _characterRoles.SetCharacterRoleAccessAsync ( getExistingRoleResult.Entity, access ); if (!setRoleAccessResult.IsSuccess) { return(setRoleAccessResult.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Character role access conditions set.")); }
public async Task <RuntimeResult> ModifyConditionAsync ( AutoroleConfiguration autorole, long conditionID, TimeSpan time ) { var getCondition = _autoroles.GetCondition <TimeSinceLastActivityCondition> ( autorole, conditionID ); if (!getCondition.IsSuccess) { return(getCondition.ToRuntimeResult()); } var condition = getCondition.Entity; var modifyResult = await _autoroles.ModifyConditionAsync ( condition, c => { condition.RequiredTime = time; } ); if (!modifyResult.IsSuccess) { return(modifyResult.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Condition updated.")); }
public async Task <RuntimeResult> InfoAsync() { var eb = _feedback.CreateEmbedBase(); eb.WithAuthor(this.Context.Client.CurrentUser); eb.WithTitle("The DIGOS Ambassador (\"Amby\")"); eb.WithImageUrl(_portraits.AmbyPortraitUri.ToString()); eb.WithDescription ( "Amby is a Discord bot written in C# using the Discord.Net and EF Core frameworks. As an ambassador for " + "the DIGOS community, she provides a number of useful services for communities with similar interests - " + "namely, roleplaying, transformation, weird and wonderful sexual kinks, and much more.\n" + "\n" + "Amby is free and open source software, licensed under the AGPLv3. All of her source code can be freely " + "viewed and improved on Github at https://github.com/Nihlus/DIGOS.Ambassador. You are free to " + "run your own instance of Amby, redistribute her code, and modify it to your heart's content. If you're " + "not familiar with the AGPL, an excellent summary is available here: " + "https://choosealicense.com/licenses/agpl-3.0/.\n" + "\n" + "Any bugs you encounter should be reported on Github, following the issue template provided there. The " + "same holds for feature requests, for which a separate template is provided. Contributions in the form " + "of code, artwork, bug triaging, or quality control testing is always greatly appreciated!\n" + "\n" + "Stay sharky~\n" + "- Amby" ); await _feedback.SendPrivateEmbedAsync(this.Context, this.Context.User, eb.Build()); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> ResetChannelPermissionsAsync() { await _feedback.SendConfirmationAsync(this.Context, "Working..."); var getRoleplays = await _discordRoleplays.GetRoleplaysAsync(this.Context.Guild); if (!getRoleplays.IsSuccess) { return(getRoleplays.ToRuntimeResult()); } var roleplays = getRoleplays.Entity.ToList(); foreach (var roleplay in roleplays) { if (!roleplay.DedicatedChannelID.HasValue) { continue; } var reset = await _dedicatedChannels.ResetChannelPermissionsAsync(this.Context.Guild, roleplay); if (!reset.IsSuccess) { await _feedback.SendErrorAsync(this.Context, reset.ErrorReason); } } return(RuntimeCommandResult.FromSuccess("Permissions reset.")); }
public async Task <RuntimeResult> ShowKinksByPreferenceAsync ( IUser otherUser, [OverrideTypeReader(typeof(HumanizerEnumTypeReader <KinkPreference>))] KinkPreference preference ) { var getUserKinksResult = await _kinks.GetUserKinksAsync(otherUser); if (!getUserKinksResult.IsSuccess) { return(getUserKinksResult.ToRuntimeResult()); } var userKinks = getUserKinksResult.Entity; var withPreference = userKinks.Where(k => k.Preference == preference).ToList(); if (!withPreference.Any()) { return(RuntimeCommandResult.FromError("The user doesn't have any kinks with that preference.")); } var paginatedKinkPages = _kinks.BuildPaginatedUserKinkEmbeds(withPreference); var paginatedMessage = new PaginatedEmbed(_feedback, _interactivity, this.Context.User) .WithPages(paginatedKinkPages); await _interactivity.SendPrivateInteractiveMessageAsync(this.Context, _feedback, paginatedMessage); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> DeleteRoleplayAsync ( [RequireEntityOwnerOrPermission(typeof(DeleteRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var deletionResult = await _discordRoleplays.DeleteRoleplayAsync(roleplay); if (!deletionResult.IsSuccess) { return(deletionResult.ToRuntimeResult()); } var canReplyInChannelAfterDeletion = (long)this.Context.Channel.Id != roleplay.DedicatedChannelID; if (canReplyInChannelAfterDeletion) { return(RuntimeCommandResult.FromSuccess($"Roleplay \"{roleplay.Name}\" deleted.")); } var eb = _feedback.CreateEmbedBase(); eb.WithDescription($"Roleplay \"{roleplay.Name}\" deleted."); await _feedback.SendPrivateEmbedAsync(this.Context, this.Context.User, eb.Build(), false); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> CreateRoleplayAsync ( string roleplayName, string roleplaySummary = "No summary set.", bool isNSFW = false, bool isPublic = true ) { if (!(this.Context.User is IGuildUser guildUser)) { return(RuntimeCommandResult.FromError("The current user isn't a guild user.")); } var result = await _discordRoleplays.CreateRoleplayAsync ( guildUser, roleplayName, roleplaySummary, isNSFW, isPublic ); if (!result.IsSuccess) { return(result.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess($"Roleplay \"{result.Entity.Name}\" created.")); }
public async Task <RuntimeResult> SetRoleplayNameAsync ( string newRoleplayName, [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)] Roleplay roleplay ) { var result = await _discordRoleplays.SetRoleplayNameAsync ( roleplay, newRoleplayName ); if (!result.IsSuccess) { return(result.ToRuntimeResult()); } var getDedicatedChannelResult = await _dedicatedChannels.GetDedicatedChannelAsync ( this.Context.Guild, roleplay ); if (!getDedicatedChannelResult.IsSuccess) { return(RuntimeCommandResult.FromSuccess("Roleplay name set.")); } var dedicatedChannel = getDedicatedChannelResult.Entity; await dedicatedChannel.ModifyAsync(p => p.Name = $"{roleplay.Name}-rp"); return(RuntimeCommandResult.FromSuccess("Roleplay name set.")); }
public async Task <RuntimeResult> ShowRoleplayAsync(Roleplay roleplay) { var eb = await CreateRoleplayInfoEmbedAsync(roleplay); await _feedback.SendEmbedAsync(this.Context.Channel, eb); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> ShowCharacterAsync(Character character) { var eb = await CreateCharacterInfoEmbedAsync(character); await ShowCharacterAsync(character, eb); 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 <RuntimeResult> IncludePreviousMessagesAsync ( [RequireEntityOwnerOrPermission(typeof(EditRoleplay), PermissionTarget.Other)] Roleplay roleplay, [OverrideTypeReader(typeof(UncachedMessageTypeReader <IMessage>))] IMessage startMessage, [OverrideTypeReader(typeof(UncachedMessageTypeReader <IMessage>))] IMessage?finalMessage = null ) { finalMessage ??= this.Context.Message; if (startMessage.Channel != finalMessage.Channel) { return(RuntimeCommandResult.FromError("The messages are not in the same channel.")); } var addedOrUpdatedMessageCount = 0; var latestMessage = startMessage; while (latestMessage.Timestamp < finalMessage.Timestamp) { var messages = (await this.Context.Channel.GetMessagesAsync ( latestMessage, Direction.After ).FlattenAsync()).OrderBy(m => m.Timestamp).ToList(); latestMessage = messages.Last(); foreach (var message in messages) { // Jump out if we've passed the final message if (message.Timestamp > finalMessage.Timestamp) { break; } if (!(message is IUserMessage userMessage)) { continue; } var modifyResult = await _discordRoleplays.ConsumeMessageAsync(userMessage); if (modifyResult.IsSuccess) { ++addedOrUpdatedMessageCount; } } } return(RuntimeCommandResult.FromSuccess ( $"{addedOrUpdatedMessageCount} messages added to \"{roleplay.Name}\"." )); }
public async Task <RuntimeResult> ShowServerStatsAsync() { var guild = this.Context.Guild; var eb = CreateGuildInfoEmbed(guild); await _feedback.SendEmbedAsync(this.Context.Channel, eb.Build()); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> BwehAsync() { var eb = _feedback.CreateEmbedBase(); eb.WithImageUrl(_portraits.BwehUri.ToString()); await _feedback.SendEmbedAsync(this.Context.Channel, eb.Build()); return(RuntimeCommandResult.FromSuccess()); }
public async Task <RuntimeResult> SetMonitoringChannelAsync(ITextChannel channel) { var setChannel = await _moderation.SetMonitoringChannelAsync(this.Context.Guild, channel); if (!setChannel.IsSuccess) { return(setChannel.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Channel set.")); }