using Discord.Net;
namespace RegexBot;
///
/// Contains information on success/failure outcomes for a warn operation.
///
public class LogAppendResult {
private readonly int _logId;
private readonly string _rptDisplayName;
///
/// Gets the exception thrown, if any, when attempting to send the warning to the target.
///
public HttpException? MessageSendError { get; }
///
/// Indicates if the operation failed due to being unable to find the user.
///
public bool ErrorNotFound => MessageSendError?.HttpCode == System.Net.HttpStatusCode.NotFound;
///
/// Indicates if the operation failed due to a permissions issue.
///
public bool ErrorForbidden => MessageSendError?.HttpCode == System.Net.HttpStatusCode.Forbidden;
///
/// Indicates if the operation completed successfully.
///
public bool Success => MessageSendError == null;
internal LogAppendResult(HttpException? error, int logId, string reportDispName) {
_logId = logId;
MessageSendError = error;
_rptDisplayName = reportDispName;
}
///
/// Returns a message representative of this result that may be posted as-is
/// within a Discord channel.
///
public string GetResultString() {
var msg = $":white_check_mark: Warning \\#{_logId} logged for {_rptDisplayName}.";
if (!Success) msg += "\n:warning: **User did not receive warning message.** This must be discussed manually.";
return msg;
}
}