@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
@@ -56,6 +57,8 @@ namespace Discord.Commands | |||||
public static ParseResult FromError(CommandError error, string reason) | public static ParseResult FromError(CommandError error, string reason) | ||||
=> new ParseResult(null, null, error, reason); | => new ParseResult(null, null, error, reason); | ||||
public static ParseResult FromError(Exception ex) | |||||
=> FromError(CommandError.Exception, ex.Message); | |||||
public static ParseResult FromError(IResult result) | public static ParseResult FromError(IResult result) | ||||
=> new ParseResult(null, null, result.Error, result.ErrorReason); | => new ParseResult(null, null, result.Error, result.ErrorReason); | ||||
@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
@@ -18,7 +19,9 @@ namespace Discord.Commands | |||||
=> new PreconditionGroupResult(null, null, null); | => new PreconditionGroupResult(null, null, null); | ||||
public static PreconditionGroupResult FromError(string reason, ICollection<PreconditionResult> preconditions) | public static PreconditionGroupResult FromError(string reason, ICollection<PreconditionResult> preconditions) | ||||
=> new PreconditionGroupResult(CommandError.UnmetPrecondition, reason, preconditions); | => new PreconditionGroupResult(CommandError.UnmetPrecondition, reason, preconditions); | ||||
public new static PreconditionGroupResult FromError(IResult result) //needed? | |||||
public static new PreconditionGroupResult FromError(Exception ex) | |||||
=> new PreconditionGroupResult(CommandError.Exception, ex.Message, null); | |||||
public static new PreconditionGroupResult FromError(IResult result) //needed? | |||||
=> new PreconditionGroupResult(result.Error, result.ErrorReason, null); | => new PreconditionGroupResult(result.Error, result.ErrorReason, null); | ||||
public override string ToString() => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; | public override string ToString() => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; | ||||
@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
@@ -40,6 +41,8 @@ namespace Discord.Commands | |||||
/// <param name="reason">The reason of failure.</param> | /// <param name="reason">The reason of failure.</param> | ||||
public static PreconditionResult FromError(string reason) | public static PreconditionResult FromError(string reason) | ||||
=> new PreconditionResult(CommandError.UnmetPrecondition, reason); | => new PreconditionResult(CommandError.UnmetPrecondition, reason); | ||||
public static PreconditionResult FromError(Exception ex) | |||||
=> new PreconditionResult(CommandError.Exception, ex.Message); | |||||
/// <summary> | /// <summary> | ||||
/// Returns a <see cref="PreconditionResult" /> with the specified <paramref name="result"/> type. | /// Returns a <see cref="PreconditionResult" /> with the specified <paramref name="result"/> type. | ||||
/// </summary> | /// </summary> | ||||
@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
@@ -29,6 +30,8 @@ namespace Discord.Commands | |||||
=> new SearchResult(text, commands, null, null); | => new SearchResult(text, commands, null, null); | ||||
public static SearchResult FromError(CommandError error, string reason) | public static SearchResult FromError(CommandError error, string reason) | ||||
=> new SearchResult(null, null, error, reason); | => new SearchResult(null, null, error, reason); | ||||
public static SearchResult FromError(Exception ex) | |||||
=> FromError(CommandError.Exception, ex.Message); | |||||
public static SearchResult FromError(IResult result) | public static SearchResult FromError(IResult result) | ||||
=> new SearchResult(null, null, result.Error, result.ErrorReason); | => new SearchResult(null, null, result.Error, result.ErrorReason); | ||||
@@ -55,6 +55,8 @@ namespace Discord.Commands | |||||
=> new TypeReaderResult(values, null, null); | => new TypeReaderResult(values, null, null); | ||||
public static TypeReaderResult FromError(CommandError error, string reason) | public static TypeReaderResult FromError(CommandError error, string reason) | ||||
=> new TypeReaderResult(null, error, reason); | => new TypeReaderResult(null, error, reason); | ||||
public static TypeReaderResult FromError(Exception ex) | |||||
=> FromError(CommandError.Exception, ex.Message); | |||||
public static TypeReaderResult FromError(IResult result) | public static TypeReaderResult FromError(IResult result) | ||||
=> new TypeReaderResult(null, result.Error, result.ErrorReason); | => new TypeReaderResult(null, result.Error, result.ErrorReason); | ||||
@@ -1,9 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Represents a generic audit log entry. | /// Represents a generic audit log entry. | ||||
/// </summary> | /// </summary> | ||||
public interface IAuditLogEntry : IEntity<ulong> | |||||
public interface IAuditLogEntry : ISnowflakeEntity | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Gets the action which occurred to create this entry. | /// Gets the action which occurred to create this entry. | ||||
@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Linq; | using System.Linq; | ||||
using Model = Discord.API.AuditLog; | using Model = Discord.API.AuditLog; | ||||
@@ -29,6 +30,8 @@ namespace Discord.Rest | |||||
return new RestAuditLogEntry(discord, fullLog, model, user); | return new RestAuditLogEntry(discord, fullLog, model, user); | ||||
} | } | ||||
/// <inheritdoc/> | |||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public ActionType Action { get; } | public ActionType Action { get; } | ||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||