Browse Source

Merge branch 'dev' into docs/pre-release

pull/1161/head
Still Hsu 7 years ago
parent
commit
ae090fb316
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
7 changed files with 25 additions and 2 deletions
  1. +3
    -0
      src/Discord.Net.Commands/Results/ParseResult.cs
  2. +4
    -1
      src/Discord.Net.Commands/Results/PreconditionGroupResult.cs
  3. +3
    -0
      src/Discord.Net.Commands/Results/PreconditionResult.cs
  4. +3
    -0
      src/Discord.Net.Commands/Results/SearchResult.cs
  5. +2
    -0
      src/Discord.Net.Commands/Results/TypeReaderResult.cs
  6. +7
    -1
      src/Discord.Net.Core/Entities/AuditLogs/IAuditLogEntry.cs
  7. +3
    -0
      src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs

+ 3
- 0
src/Discord.Net.Commands/Results/ParseResult.cs View File

@@ -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);




+ 4
- 1
src/Discord.Net.Commands/Results/PreconditionGroupResult.cs View File

@@ -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}";


+ 3
- 0
src/Discord.Net.Commands/Results/PreconditionResult.cs View File

@@ -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>


+ 3
- 0
src/Discord.Net.Commands/Results/SearchResult.cs View File

@@ -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);




+ 2
- 0
src/Discord.Net.Commands/Results/TypeReaderResult.cs View File

@@ -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);




+ 7
- 1
src/Discord.Net.Core/Entities/AuditLogs/IAuditLogEntry.cs View File

@@ -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.


+ 3
- 0
src/Discord.Net.Rest/Entities/AuditLogs/RestAuditLogEntry.cs View File

@@ -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/>


Loading…
Cancel
Save