@@ -20,12 +20,14 @@ namespace Discord.API | |||||
[JsonProperty("tts")] | [JsonProperty("tts")] | ||||
public Optional<bool> IsTextToSpeech { get; set; } | public Optional<bool> IsTextToSpeech { get; set; } | ||||
[JsonProperty("mention_everyone")] | [JsonProperty("mention_everyone")] | ||||
public Optional<bool> IsMentioningEveryone { get; set; } | |||||
public Optional<bool> MentionEveryone { get; set; } | |||||
[JsonProperty("mentions")] | [JsonProperty("mentions")] | ||||
public Optional<User[]> Mentions { get; set; } | public Optional<User[]> Mentions { get; set; } | ||||
[JsonProperty("attachments")] | [JsonProperty("attachments")] | ||||
public Optional<Attachment[]> Attachments { get; set; } | public Optional<Attachment[]> Attachments { get; set; } | ||||
[JsonProperty("embeds")] | [JsonProperty("embeds")] | ||||
public Optional<Embed[]> Embeds { get; set; } | public Optional<Embed[]> Embeds { get; set; } | ||||
[JsonProperty("pinned")] | |||||
public Optional<bool> Pinned { get; set; } | |||||
} | } | ||||
} | } |
@@ -494,15 +494,37 @@ namespace Discord.API | |||||
//Channel Permissions | //Channel Permissions | ||||
public async Task ModifyChannelPermissionsAsync(ulong channelId, ulong targetId, ModifyChannelPermissionsParams args, RequestOptions options = null) | public async Task ModifyChannelPermissionsAsync(ulong channelId, ulong targetId, ModifyChannelPermissionsParams args, RequestOptions options = null) | ||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | |||||
Preconditions.NotEqual(targetId, 0, nameof(targetId)); | |||||
Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
await SendAsync("PUT", $"channels/{channelId}/permissions/{targetId}", args, options: options).ConfigureAwait(false); | await SendAsync("PUT", $"channels/{channelId}/permissions/{targetId}", args, options: options).ConfigureAwait(false); | ||||
} | } | ||||
public async Task DeleteChannelPermissionAsync(ulong channelId, ulong targetId, RequestOptions options = null) | public async Task DeleteChannelPermissionAsync(ulong channelId, ulong targetId, RequestOptions options = null) | ||||
{ | { | ||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | |||||
Preconditions.NotEqual(targetId, 0, nameof(targetId)); | |||||
await SendAsync("DELETE", $"channels/{channelId}/permissions/{targetId}", options: options).ConfigureAwait(false); | await SendAsync("DELETE", $"channels/{channelId}/permissions/{targetId}", options: options).ConfigureAwait(false); | ||||
} | } | ||||
//Channel Pins | |||||
public async Task AddPinAsync(ulong channelId, ulong messageId, RequestOptions options = null) | |||||
{ | |||||
Preconditions.GreaterThan(channelId, 0, nameof(channelId)); | |||||
Preconditions.GreaterThan(messageId, 0, nameof(messageId)); | |||||
await SendAsync("PUT", $"channels/{channelId}/pins/{messageId}", options: options).ConfigureAwait(false); | |||||
} | |||||
public async Task RemovePinAsync(ulong channelId, ulong messageId, RequestOptions options = null) | |||||
{ | |||||
Preconditions.NotEqual(channelId, 0, nameof(channelId)); | |||||
Preconditions.NotEqual(messageId, 0, nameof(messageId)); | |||||
await SendAsync("DELETE", $"channels/{channelId}/pins/{messageId}", options: options).ConfigureAwait(false); | |||||
} | |||||
//Guilds | //Guilds | ||||
public async Task<Guild> GetGuildAsync(ulong guildId, RequestOptions options = null) | public async Task<Guild> GetGuildAsync(ulong guildId, RequestOptions options = null) | ||||
{ | { | ||||
@@ -11,6 +11,8 @@ namespace Discord | |||||
DateTimeOffset? EditedTimestamp { get; } | DateTimeOffset? EditedTimestamp { get; } | ||||
/// <summary> Returns true if this message was sent as a text-to-speech message. </summary> | /// <summary> Returns true if this message was sent as a text-to-speech message. </summary> | ||||
bool IsTTS { get; } | bool IsTTS { get; } | ||||
/// <summary> Returns true if this message was added to its channel's pinned messages. </summary> | |||||
bool IsPinned { get; } | |||||
/// <summary> Returns the original, unprocessed text for this message. </summary> | /// <summary> Returns the original, unprocessed text for this message. </summary> | ||||
string RawText { get; } | string RawText { get; } | ||||
/// <summary> Returns the text for this message after mention processing. </summary> | /// <summary> Returns the text for this message after mention processing. </summary> | ||||
@@ -35,5 +37,9 @@ namespace Discord | |||||
/// <summary> Modifies this message. </summary> | /// <summary> Modifies this message. </summary> | ||||
Task ModifyAsync(Action<ModifyMessageParams> func); | Task ModifyAsync(Action<ModifyMessageParams> func); | ||||
/// <summary> Adds this message to its channel's pinned messages. </summary> | |||||
Task PinAsync(); | |||||
/// <summary> Removes this message from its channel's pinned messages. </summary> | |||||
Task UnpinAsync(); | |||||
} | } | ||||
} | } |
@@ -18,6 +18,7 @@ namespace Discord | |||||
public bool IsTTS { get; private set; } | public bool IsTTS { get; private set; } | ||||
public string RawText { get; private set; } | public string RawText { get; private set; } | ||||
public string Text { get; private set; } | public string Text { get; private set; } | ||||
public bool IsPinned { get; private set; } | |||||
public IMessageChannel Channel { get; } | public IMessageChannel Channel { get; } | ||||
public IUser Author { get; } | public IUser Author { get; } | ||||
@@ -57,13 +58,15 @@ namespace Discord | |||||
if (model.IsTextToSpeech.IsSpecified) | if (model.IsTextToSpeech.IsSpecified) | ||||
IsTTS = model.IsTextToSpeech.Value; | IsTTS = model.IsTextToSpeech.Value; | ||||
if (model.Pinned.IsSpecified) | |||||
IsPinned = model.Pinned.Value; | |||||
if (model.Timestamp.IsSpecified) | if (model.Timestamp.IsSpecified) | ||||
_timestampTicks = model.Timestamp.Value.UtcTicks; | _timestampTicks = model.Timestamp.Value.UtcTicks; | ||||
if (model.EditedTimestamp.IsSpecified) | if (model.EditedTimestamp.IsSpecified) | ||||
_editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; | ||||
if (model.IsMentioningEveryone.IsSpecified) | |||||
_isMentioningEveryone = model.IsMentioningEveryone.Value; | |||||
if (model.MentionEveryone.IsSpecified) | |||||
_isMentioningEveryone = model.MentionEveryone.Value; | |||||
if (model.Attachments.IsSpecified) | if (model.Attachments.IsSpecified) | ||||
{ | { | ||||
var value = model.Attachments.Value; | var value = model.Attachments.Value; | ||||
@@ -144,6 +147,9 @@ namespace Discord | |||||
model = await Discord.ApiClient.ModifyMessageAsync(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); | model = await Discord.ApiClient.ModifyMessageAsync(guildChannel.Guild.Id, Channel.Id, Id, args).ConfigureAwait(false); | ||||
else | else | ||||
model = await Discord.ApiClient.ModifyDMMessageAsync(Channel.Id, Id, args).ConfigureAwait(false); | model = await Discord.ApiClient.ModifyDMMessageAsync(Channel.Id, Id, args).ConfigureAwait(false); | ||||
{ | |||||
await Discord.ApiClient.AddPinAsync(Channel.Id, Id).ConfigureAwait(false); | |||||
} | |||||
Update(model, UpdateSource.Rest); | Update(model, UpdateSource.Rest); | ||||
} | } | ||||
public async Task DeleteAsync() | public async Task DeleteAsync() | ||||
@@ -154,6 +160,16 @@ namespace Discord | |||||
else | else | ||||
await Discord.ApiClient.DeleteDMMessageAsync(Channel.Id, Id).ConfigureAwait(false); | await Discord.ApiClient.DeleteDMMessageAsync(Channel.Id, Id).ConfigureAwait(false); | ||||
} | } | ||||
/// <summary> Adds this message to its channel's pinned messages. </summary> | |||||
public async Task PinAsync() | |||||
{ | |||||
await Discord.ApiClient.AddPinAsync(Channel.Id, Id).ConfigureAwait(false); | |||||
} | |||||
/// <summary> Removes this message from its channel's pinned messages. </summary> | |||||
public async Task UnpinAsync() | |||||
{ | |||||
await Discord.ApiClient.RemovePinAsync(Channel.Id, Id).ConfigureAwait(false); | |||||
} | |||||
public override string ToString() => Text; | public override string ToString() => Text; | ||||
private string DebuggerDisplay => $"{Author}: {Text}{(Attachments.Length > 0 ? $" [{Attachments.Length} Attachments]" : "")}"; | private string DebuggerDisplay => $"{Author}: {Text}{(Attachments.Length > 0 ? $" [{Attachments.Length} Attachments]" : "")}"; | ||||