using Discord.Net; namespace Kerobot { // Instances of this are created by CommonFunctionService and by ModuleBase on behalf of CommonFunctionService, // and are meant to be sent to modules. This class has therefore been put within the Kerobot namespace. /// /// Contains information on various success/failure outcomes for a ban or kick operation. /// public class BanKickResult { private readonly bool _userNotFound; internal BanKickResult(HttpException error, bool notificationSuccess, bool errorNotFound) { OperationError = error; MessageSendSuccess = notificationSuccess; _userNotFound = errorNotFound; } /// /// Gets a value indicating whether the kick or ban succeeded. /// public bool OperationSuccess { get { if (ErrorNotFound) return false; if (OperationError == null) return false; return true; } } /// /// The exception thrown, if any, when attempting to kick or ban the target. /// public HttpException OperationError { get; } /// /// Indicates if the operation failed due to being unable to find the user. /// public bool ErrorNotFound { get { if (_userNotFound) return true; // TODO I don't like this. if (OperationSuccess) return false; return OperationError.HttpCode == System.Net.HttpStatusCode.NotFound; } } /// /// Indicates if the operation failed due to a permissions issue. /// public bool ErrorForbidden { get { if (OperationSuccess) return false; return OperationError.HttpCode == System.Net.HttpStatusCode.Forbidden; } } /// /// Gets a value indicating whether the user was able to receive the ban or kick message. /// /// /// if an error was encountered when attempting to send the target a DM. Will always /// return otherwise, including cases in which no message was sent. /// public bool MessageSendSuccess { get; } } }