Skip to content

Commit

Permalink
fun ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Oct 17, 2023
1 parent 609c8bd commit 29f9a4e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions DisCatSharp/Entities/Guild/AuditLog/DiscordAuditLogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public class DiscordAuditLogEntry : SnowflakeObject
/// <exception cref="InvalidCastException">Thrown when the <see cref="ActionType"/> is not compatible with the targets <see cref="AuditLogChangeSet.ValidFor"/> type.</exception>
public T? As<T>()
where T : AuditLogChangeSet
{
if (this is T { IsValid: true } toConvert)
return toConvert;

throw new InvalidCastException($"Cannot convert {this.GetType().Name} with action type {this.ActionType} to {typeof(T).Name}.");
}
=> this is T { IsValid: true } toConvert
? toConvert
: throw new InvalidCastException($"Cannot convert {this.GetType().Name} with action type {this.ActionType} to {typeof(T).Name}.");
}

0 comments on commit 29f9a4e

Please sign in to comment.