[Feature] add Thread property to RestMessage (#2575)
This commit is contained in:
@@ -64,5 +64,8 @@ namespace Discord.API
|
|||||||
public Optional<StickerItem[]> StickerItems { get; set; }
|
public Optional<StickerItem[]> StickerItems { get; set; }
|
||||||
[JsonProperty("role_subscription_data")]
|
[JsonProperty("role_subscription_data")]
|
||||||
public Optional<MessageRoleSubscriptionData> RoleSubscriptionData { get; set; }
|
public Optional<MessageRoleSubscriptionData> RoleSubscriptionData { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("thread")]
|
||||||
|
public Optional<Channel> Thread { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,10 +80,19 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public MessageType Type { get; private set; }
|
public MessageType Type { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the thread that was started from this message.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="RestThreadChannel"/> object if this message has thread attached; otherwise <see langword="null"/>.
|
||||||
|
/// </returns>
|
||||||
|
public RestThreadChannel Thread { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; }
|
public MessageRoleSubscriptionData RoleSubscriptionData { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc cref="IMessage.Components"/>
|
||||||
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; }
|
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a collection of the mentioned users in the message.
|
/// Gets a collection of the mentioned users in the message.
|
||||||
@@ -255,6 +264,11 @@ namespace Discord.Rest
|
|||||||
model.RoleSubscriptionData.Value.MonthsSubscribed,
|
model.RoleSubscriptionData.Value.MonthsSubscribed,
|
||||||
model.RoleSubscriptionData.Value.IsRenewal);
|
model.RoleSubscriptionData.Value.IsRenewal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.Thread.IsSpecified)
|
||||||
|
{
|
||||||
|
Thread = RestThreadChannel.Create(Discord, new RestGuild(Discord, model.Thread.Value.GuildId.Value), model.Thread.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task UpdateAsync(RequestOptions options = null)
|
public async Task UpdateAsync(RequestOptions options = null)
|
||||||
@@ -274,11 +288,17 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public override string ToString() => Content;
|
public override string ToString() => Content;
|
||||||
|
|
||||||
|
#region IMessage
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IUser IMessage.Author => Author;
|
IUser IMessage.Author => Author;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IReadOnlyCollection<IAttachment> IMessage.Attachments => Attachments;
|
IReadOnlyCollection<IAttachment> IMessage.Attachments => Attachments;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds;
|
IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray();
|
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray();
|
||||||
|
|
||||||
@@ -290,6 +310,8 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IReadOnlyCollection<IStickerItem> IMessage.Stickers => Stickers;
|
IReadOnlyCollection<IStickerItem> IMessage.Stickers => Stickers;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emote, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me });
|
public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emote, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me });
|
||||||
|
|||||||
Reference in New Issue
Block a user