/// <summary> /// Removes the given character's bodypart. /// </summary> /// <param name="invokingUser">The user that's performing the action.</param> /// <param name="character">The character to shift.</param> /// <param name="bodyPart">The bodypart to remove.</param> /// <param name="chirality">The chirality of the bodypart.</param> /// <param name="ct">The cancellation token in use.</param> /// <returns>A shifting result which may or may not have succeeded.</returns> public async Task <Result <ShiftBodypartResult> > RemoveBodypartAsync ( Snowflake invokingUser, Character character, Bodypart bodyPart, Chirality chirality = Chirality.Center, CancellationToken ct = default ) { var canTransformResult = await CanUserTransformUserAsync ( character.Server.DiscordID, invokingUser, character.Owner.DiscordID, ct ); if (!canTransformResult.IsSuccess) { return(Result <ShiftBodypartResult> .FromError(canTransformResult)); } var getAppearanceResult = await GetOrCreateCurrentAppearanceAsync(character, ct); if (!getAppearanceResult.IsSuccess) { return(Result <ShiftBodypartResult> .FromError(getAppearanceResult)); } var appearance = getAppearanceResult.Entity; var bodypartRemover = new BodypartRemover ( appearance, _descriptionBuilder ); var shiftResult = await bodypartRemover.RemoveAsync(bodyPart, chirality); if (shiftResult.IsSuccess) { await _database.SaveChangesAsync(ct); } return(shiftResult); }
/// <summary> /// Removes the given character's bodypart. /// </summary> /// <param name="context">The context of the command.</param> /// <param name="character">The character to shift.</param> /// <param name="bodyPart">The bodypart to remove.</param> /// <param name="chirality">The chirality of the bodypart.</param> /// <returns>A shifting result which may or may not have succeeded.</returns> public async Task <ShiftBodypartResult> RemoveBodypartAsync ( ICommandContext context, Character character, Bodypart bodyPart, Chirality chirality = Chirality.Center ) { var discordUser = await context.Guild.GetUserAsync((ulong)character.Owner.DiscordID); var canTransformResult = await CanUserTransformUserAsync(context.Guild, context.User, discordUser); if (!canTransformResult.IsSuccess) { return(ShiftBodypartResult.FromError(canTransformResult)); } var getAppearanceResult = await GetOrCreateCurrentAppearanceAsync(character); if (!getAppearanceResult.IsSuccess) { return(ShiftBodypartResult.FromError(getAppearanceResult)); } var appearance = getAppearanceResult.Entity; var bodypartRemover = new BodypartRemover ( appearance, _descriptionBuilder ); var shiftResult = await bodypartRemover.RemoveAsync(bodyPart, chirality); if (shiftResult.IsSuccess) { await _database.SaveChangesAsync(); } return(shiftResult); }