public async Task DeleteWarningAsync(long warningID) { var getWarning = await _warnings.GetWarningAsync(this.Context.Guild, warningID); if (!getWarning.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getWarning.ErrorReason); return; } var warning = getWarning.Entity; var deleteWarning = await _warnings.DeleteWarningAsync(warning); if (!deleteWarning.IsSuccess) { await _feedback.SendErrorAsync(this.Context, deleteWarning.ErrorReason); return; } await _feedback.SendConfirmationAsync(this.Context, "Warning deleted."); var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id); await _logging.NotifyUserWarningRemoved(warning, rescinder); }
public async Task <Result <FeedbackMessage> > DeleteWarningAsync(long warningID) { var getWarning = await _warnings.GetWarningAsync(_context.GuildID.Value, warningID); if (!getWarning.IsSuccess) { return(Result <FeedbackMessage> .FromError(getWarning)); } var warning = getWarning.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 notifyResult = await _logging.NotifyUserWarningRemovedAsync(warning, _context.User.ID); if (!notifyResult.IsSuccess) { return(Result <FeedbackMessage> .FromError(notifyResult)); } var deleteWarning = await _warnings.DeleteWarningAsync(warning); return(deleteWarning.IsSuccess ? new FeedbackMessage("Warning deleted.", _feedback.Theme.Secondary) : Result <FeedbackMessage> .FromError(deleteWarning)); }
public async Task <RuntimeResult> DeleteWarningAsync(long warningID) { var getWarning = await _warnings.GetWarningAsync(this.Context.Guild, warningID); if (!getWarning.IsSuccess) { return(getWarning.ToRuntimeResult()); } var warning = getWarning.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.NotifyUserWarningRemovedAsync(warning, rescinder); if (!notifyResult.IsSuccess) { return(notifyResult.ToRuntimeResult()); } var deleteWarning = await _warnings.DeleteWarningAsync(warning); if (!deleteWarning.IsSuccess) { return(deleteWarning.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Warning deleted.")); }
public async Task DeleteWarningAsync(long warningID) { var getWarning = await _warnings.GetWarningAsync(this.Context.Guild, warningID); if (!getWarning.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getWarning.ErrorReason); return; } var warning = getWarning.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); await _logging.NotifyUserWarningRemoved(warning, rescinder); var deleteWarning = await _warnings.DeleteWarningAsync(warning); if (!deleteWarning.IsSuccess) { await _feedback.SendErrorAsync(this.Context, deleteWarning.ErrorReason); return; } await _feedback.SendConfirmationAsync(this.Context, "Warning deleted."); }
public async Task <Result <FeedbackMessage> > SetWarningReasonAsync(long warningID, string newReason) { var getWarning = await _warnings.GetWarningAsync(_context.GuildID.Value, warningID); if (!getWarning.IsSuccess) { return(Result <FeedbackMessage> .FromError(getWarning)); } var warning = getWarning.Entity; var setContents = await _warnings.SetWarningReasonAsync(warning, newReason); return(setContents.IsSuccess ? new FeedbackMessage("Warning reason updated.", _feedback.Theme.Secondary) : Result <FeedbackMessage> .FromError(setContents)); }
public async Task <RuntimeResult> SetWarningReasonAsync(long warningID, string newReason) { var getWarning = await _warnings.GetWarningAsync(this.Context.Guild, warningID); if (!getWarning.IsSuccess) { return(getWarning.ToRuntimeResult()); } var warning = getWarning.Entity; var setContents = await _warnings.SetWarningReasonAsync(warning, newReason); if (!setContents.IsSuccess) { return(setContents.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Warning reason updated.")); }
public async Task SetWarningReasonAsync(long warningID, string newReason) { var getWarning = await _warnings.GetWarningAsync(this.Context.Guild, warningID); if (!getWarning.IsSuccess) { await _feedback.SendErrorAsync(this.Context, getWarning.ErrorReason); return; } var warning = getWarning.Entity; var setContents = await _warnings.SetWarningReasonAsync(warning, newReason); if (!setContents.IsSuccess) { await _feedback.SendErrorAsync(this.Context, setContents.ErrorReason); return; } await _feedback.SendConfirmationAsync(this.Context, "Warning reason updated."); }