| @@ -31,6 +31,13 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| bool IsPinned { get; } | bool IsPinned { get; } | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets the value that indicates whether or not this message's embeds are suppressed. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// <c>true</c> if the embeds in this message have been suppressed (made invisible); otherwise <c>false</c>. | |||||
| /// </returns> | |||||
| bool IsSuppressed { get; } | |||||
| /// <summary> | |||||
| /// Gets the content for this message. | /// Gets the content for this message. | ||||
| /// </summary> | /// </summary> | ||||
| /// <returns> | /// <returns> | ||||
| @@ -29,6 +29,18 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null); | Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null); | ||||
| /// <summary> | /// <summary> | ||||
| /// Modifies the suppression of this message. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// This method modifies whether or not embeds in this message are suppressed (hidden). | |||||
| /// </remarks> | |||||
| /// <param name="suppressEmbeds">Whether or not embeds in this message should be suppressed.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous modification operation. | |||||
| /// </returns> | |||||
| Task ModifySuppressionAsync(bool suppressEmbeds, RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Adds this message to its channel's pinned messages. | /// Adds this message to its channel's pinned messages. | ||||
| /// </summary> | /// </summary> | ||||
| /// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
| @@ -50,5 +50,7 @@ namespace Discord.API | |||||
| // sent with Rich Presence-related chat embeds | // sent with Rich Presence-related chat embeds | ||||
| [JsonProperty("application")] | [JsonProperty("application")] | ||||
| public Optional<MessageApplication> Application { get; set; } | public Optional<MessageApplication> Application { get; set; } | ||||
| [JsonProperty("flags")] | |||||
| public Optional<MessageFlags> Flags { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -608,6 +608,16 @@ namespace Discord.API | |||||
| return await SendJsonAsync<Message>("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); | return await SendJsonAsync<Message>("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task SuppressEmbedAsync(ulong channelId, ulong messageId, Rest.SuppressEmbedParams args, RequestOptions options = null) | |||||
| { | |||||
| Preconditions.NotEqual(channelId, 0, nameof(channelId)); | |||||
| Preconditions.NotEqual(messageId, 0, nameof(messageId)); | |||||
| options = RequestOptions.CreateOrClone(options); | |||||
| var ids = new BucketIds(channelId: channelId); | |||||
| await SendJsonAsync("POST", () => $"channels/{channelId}/messages/{messageId}/suppress-embeds", args, ids, options: options).ConfigureAwait(false); | |||||
| } | |||||
| public async Task AddReactionAsync(ulong channelId, ulong messageId, string emoji, RequestOptions options = null) | public async Task AddReactionAsync(ulong channelId, ulong messageId, string emoji, RequestOptions options = null) | ||||
| { | { | ||||
| Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
| @@ -20,6 +20,7 @@ namespace Discord.Rest | |||||
| var args = new MessageProperties(); | var args = new MessageProperties(); | ||||
| func(args); | func(args); | ||||
| var apiArgs = new API.Rest.ModifyMessageParams | var apiArgs = new API.Rest.ModifyMessageParams | ||||
| { | { | ||||
| Content = args.Content, | Content = args.Content, | ||||
| @@ -35,6 +36,15 @@ namespace Discord.Rest | |||||
| await client.ApiClient.DeleteMessageAsync(channelId, msgId, options).ConfigureAwait(false); | await client.ApiClient.DeleteMessageAsync(channelId, msgId, options).ConfigureAwait(false); | ||||
| } | } | ||||
| public static async Task SuppressEmbedsAsync(IMessage msg, BaseDiscordClient client, bool suppress, RequestOptions options) | |||||
| { | |||||
| var apiArgs = new API.Rest.SuppressEmbedParams | |||||
| { | |||||
| Suppressed = suppress | |||||
| }; | |||||
| await client.ApiClient.SuppressEmbedAsync(msg.Channel.Id, msg.Id, apiArgs, options).ConfigureAwait(false); | |||||
| } | |||||
| public static async Task AddReactionAsync(IMessage msg, IEmote emote, BaseDiscordClient client, RequestOptions options) | public static async Task AddReactionAsync(IMessage msg, IEmote emote, BaseDiscordClient client, RequestOptions options) | ||||
| { | { | ||||
| await client.ApiClient.AddReactionAsync(msg.Channel.Id, msg.Id, emote is Emote e ? $"{e.Name}:{e.Id}" : emote.Name, options).ConfigureAwait(false); | await client.ApiClient.AddReactionAsync(msg.Channel.Id, msg.Id, emote is Emote e ? $"{e.Name}:{e.Id}" : emote.Name, options).ConfigureAwait(false); | ||||
| @@ -33,6 +33,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public virtual bool IsPinned => false; | public virtual bool IsPinned => false; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public virtual bool IsSuppressed => false; | |||||
| /// <inheritdoc /> | |||||
| public virtual DateTimeOffset? EditedTimestamp => null; | public virtual DateTimeOffset? EditedTimestamp => null; | ||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of the <see cref="Attachment"/>'s on the message. | /// Gets a collection of the <see cref="Attachment"/>'s on the message. | ||||
| @@ -14,7 +14,7 @@ namespace Discord.Rest | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class RestUserMessage : RestMessage, IUserMessage | public class RestUserMessage : RestMessage, IUserMessage | ||||
| { | { | ||||
| private bool _isMentioningEveryone, _isTTS, _isPinned; | |||||
| private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed; | |||||
| private long? _editedTimestampTicks; | private long? _editedTimestampTicks; | ||||
| private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>(); | private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>(); | ||||
| private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>(); | private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>(); | ||||
| @@ -26,6 +26,8 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override bool IsPinned => _isPinned; | public override bool IsPinned => _isPinned; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override bool IsSuppressed => _isSuppressed; | |||||
| /// <inheritdoc /> | |||||
| public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<Attachment> Attachments => _attachments; | public override IReadOnlyCollection<Attachment> Attachments => _attachments; | ||||
| @@ -65,6 +67,10 @@ namespace Discord.Rest | |||||
| _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | ||||
| if (model.MentionEveryone.IsSpecified) | if (model.MentionEveryone.IsSpecified) | ||||
| _isMentioningEveryone = model.MentionEveryone.Value; | _isMentioningEveryone = model.MentionEveryone.Value; | ||||
| if (model.Flags.IsSpecified) | |||||
| { | |||||
| _isSuppressed = model.Flags.Value.HasFlag(API.MessageFlags.Suppressed); | |||||
| } | |||||
| if (model.Attachments.IsSpecified) | if (model.Attachments.IsSpecified) | ||||
| { | { | ||||
| @@ -163,6 +169,9 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task UnpinAsync(RequestOptions options = null) | public Task UnpinAsync(RequestOptions options = null) | ||||
| => MessageHelper.UnpinAsync(this, Discord, options); | => MessageHelper.UnpinAsync(this, Discord, options); | ||||
| /// <inheritdoc /> | |||||
| public Task ModifySuppressionAsync(bool suppressEmbeds, RequestOptions options = null) | |||||
| => MessageHelper.SuppressEmbedsAsync(this, Discord, suppressEmbeds, options); | |||||
| public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | ||||
| TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | ||||
| @@ -42,6 +42,8 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public virtual bool IsPinned => false; | public virtual bool IsPinned => false; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public virtual bool IsSuppressed => false; | |||||
| /// <inheritdoc /> | |||||
| public virtual DateTimeOffset? EditedTimestamp => null; | public virtual DateTimeOffset? EditedTimestamp => null; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -16,7 +16,7 @@ namespace Discord.WebSocket | |||||
| public class SocketUserMessage : SocketMessage, IUserMessage | public class SocketUserMessage : SocketMessage, IUserMessage | ||||
| { | { | ||||
| private readonly List<SocketReaction> _reactions = new List<SocketReaction>(); | private readonly List<SocketReaction> _reactions = new List<SocketReaction>(); | ||||
| private bool _isMentioningEveryone, _isTTS, _isPinned; | |||||
| private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed; | |||||
| private long? _editedTimestampTicks; | private long? _editedTimestampTicks; | ||||
| private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>(); | private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>(); | ||||
| private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>(); | private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>(); | ||||
| @@ -27,6 +27,8 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override bool IsPinned => _isPinned; | public override bool IsPinned => _isPinned; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override bool IsSuppressed => _isSuppressed; | |||||
| /// <inheritdoc /> | |||||
| public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<Attachment> Attachments => _attachments; | public override IReadOnlyCollection<Attachment> Attachments => _attachments; | ||||
| @@ -66,6 +68,10 @@ namespace Discord.WebSocket | |||||
| _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | ||||
| if (model.MentionEveryone.IsSpecified) | if (model.MentionEveryone.IsSpecified) | ||||
| _isMentioningEveryone = model.MentionEveryone.Value; | _isMentioningEveryone = model.MentionEveryone.Value; | ||||
| if (model.Flags.IsSpecified) | |||||
| { | |||||
| _isSuppressed = model.Flags.Value.HasFlag(API.MessageFlags.Suppressed); | |||||
| } | |||||
| if (model.Attachments.IsSpecified) | if (model.Attachments.IsSpecified) | ||||
| { | { | ||||
| @@ -159,6 +165,9 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task UnpinAsync(RequestOptions options = null) | public Task UnpinAsync(RequestOptions options = null) | ||||
| => MessageHelper.UnpinAsync(this, Discord, options); | => MessageHelper.UnpinAsync(this, Discord, options); | ||||
| /// <inheritdoc /> | |||||
| public Task ModifySuppressionAsync(bool suppressEmbeds, RequestOptions options = null) | |||||
| => MessageHelper.SuppressEmbedsAsync(this, Discord, suppressEmbeds, options); | |||||
| public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name, | ||||
| TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name) | ||||