| @@ -60,10 +60,5 @@ namespace Discord.Commands | |||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Gets wheter the message's attachments are spoilers or not. | |||||
| /// </summary> | |||||
| public static bool IsSpoiler(this IAttachment attachment) | |||||
| => attachment.Filename.StartsWith("SPOILER_"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -5,6 +5,11 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public interface IAttachment | public interface IAttachment | ||||
| { | { | ||||
| /// <summary> | |||||
| /// The prefix applied to files to indicate that it is a spoiler. | |||||
| /// </summary> | |||||
| public const string SpoilerPrefix = "SPOILER_"; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the ID of this attachment. | /// Gets the ID of this attachment. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -0,0 +1,11 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public static class AttachmentExtensions | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets wheter the message's attachments are spoilers or not. | |||||
| /// </summary> | |||||
| public static bool IsSpoiler(this IAttachment attachment) | |||||
| => attachment.Filename.StartsWith(IAttachment.SpoilerPrefix); | |||||
| } | |||||
| } | |||||
| @@ -30,8 +30,8 @@ namespace Discord.API.Rest | |||||
| { | { | ||||
| var d = new Dictionary<string, object>(); | var d = new Dictionary<string, object>(); | ||||
| var filename = Filename.GetValueOrDefault("unknown.dat"); | var filename = Filename.GetValueOrDefault("unknown.dat"); | ||||
| if (IsSpoiler && !filename.StartsWith("SPOILER_")) | |||||
| filename = filename.Insert(0, "SPOILER_"); | |||||
| if (IsSpoiler && !filename.StartsWith(IAttachment.SpoilerPrefix)) | |||||
| filename = filename.Insert(0, IAttachment.SpoilerPrefix); | |||||
| d["file"] = new MultipartFile(File, filename); | d["file"] = new MultipartFile(File, filename); | ||||
| var payload = new Dictionary<string, object>(); | var payload = new Dictionary<string, object>(); | ||||