-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5af2e00
commit 86cd3e6
Showing
17 changed files
with
230 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/Disqord.Core/Entities/Core/Message/User/IMessageSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Disqord; | ||
|
||
public interface IMessageSnapshot : IEntity | ||
{ | ||
/// <summary> | ||
/// Gets the <see cref="UserMessageType"/> of this message snapshot. | ||
/// </summary> | ||
UserMessageType Type { get; } | ||
|
||
/// <summary> | ||
/// Gets the content of this message snapshot. | ||
/// </summary> | ||
string Content { get; } | ||
|
||
/// <summary> | ||
/// Gets the mentioned users of this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<IUser> MentionedUsers { get; } | ||
|
||
/// <summary> | ||
/// Gets the mentioned role IDs of this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<Snowflake> MentionedRoleIds { get; } | ||
|
||
/// <summary> | ||
/// Gets the attachments of this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<IAttachment> Attachments { get; } | ||
|
||
/// <summary> | ||
/// Gets the embeds of this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<IEmbed> Embeds { get; } | ||
|
||
/// <summary> | ||
/// Gets the timestamp of when the snapshotted message was created. | ||
/// </summary> | ||
DateTimeOffset Timestamp { get; } | ||
|
||
/// <summary> | ||
/// Gets the edit date of this message snapshot. | ||
/// </summary> | ||
DateTimeOffset? EditedAt { get; } | ||
|
||
/// <summary> | ||
/// Gets the flags of this message snapshot. | ||
/// </summary> | ||
MessageFlags Flags { get; } | ||
|
||
/// <summary> | ||
/// Gets the stickers sent with this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<IMessageSticker> Stickers { get; } | ||
|
||
/// <summary> | ||
/// Gets the components of this message snapshot. | ||
/// </summary> | ||
IReadOnlyList<IRowComponent> Components { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/Disqord.Core/Entities/Transient/Message/User/TransientMessageSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Disqord.Models; | ||
using Qommon.Collections.ReadOnly; | ||
|
||
namespace Disqord; | ||
|
||
public class TransientMessageSnapshot : TransientClientEntity<MessageSnapshotJsonModel>, IMessageSnapshot | ||
{ | ||
/// <inheritdoc/> | ||
public UserMessageType Type => Model.Message.Type; | ||
|
||
/// <inheritdoc/> | ||
public string Content => Model.Message.Content; | ||
|
||
/// <inheritdoc/> | ||
public IReadOnlyList<IUser> MentionedUsers => _mentionedUsers ??= Model.Message.Mentions.ToReadOnlyList(Client, (model, client) => new TransientUser(client, model)); | ||
|
||
private IReadOnlyList<IUser>? _mentionedUsers; | ||
|
||
/// <inheritdoc/> | ||
public IReadOnlyList<Snowflake> MentionedRoleIds => Model.Message.MentionRoles; | ||
|
||
/// <inheritdoc/> | ||
public IReadOnlyList<IAttachment> Attachments => _attachments ??= Model.Message.Attachments.ToReadOnlyList(model => new TransientAttachment(model)); | ||
|
||
private IReadOnlyList<IAttachment>? _attachments; | ||
|
||
/// <inheritdoc/> | ||
public IReadOnlyList<IEmbed> Embeds => _embeds ??= Model.Message.Embeds.ToReadOnlyList(model => new TransientEmbed(model)); | ||
|
||
private IReadOnlyList<IEmbed>? _embeds; | ||
|
||
/// <inheritdoc/> | ||
public DateTimeOffset Timestamp { get; } | ||
|
||
/// <inheritdoc/> | ||
public DateTimeOffset? EditedAt { get; } | ||
|
||
/// <inheritdoc/> | ||
public MessageFlags Flags { get; } | ||
|
||
/// <inheritdoc/> | ||
public IReadOnlyList<IMessageSticker> Stickers | ||
{ | ||
get | ||
{ | ||
if (!Model.Message.StickerItems.HasValue) | ||
return Array.Empty<IMessageSticker>(); | ||
|
||
return _stickers ??= Model.Message.StickerItems.Value.ToReadOnlyList(model => new TransientMessageSticker(model)); | ||
} | ||
} | ||
|
||
private IReadOnlyList<IMessageSticker>? _stickers; | ||
|
||
public IReadOnlyList<IRowComponent> Components | ||
{ | ||
get | ||
{ | ||
if (!Model.Message.Components.HasValue) | ||
return Array.Empty<IRowComponent>(); | ||
|
||
return _components ??= Model.Message.Components.Value.ToReadOnlyList(Client, (model, client) => new TransientRowComponent(client, model)); | ||
} | ||
} | ||
private IReadOnlyList<IRowComponent>? _components; | ||
|
||
public TransientMessageSnapshot(IClient client, MessageSnapshotJsonModel model) | ||
: base(client, model) | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Disqord; | ||
|
||
/// <summary> | ||
/// Represents the type of a message reference. | ||
/// </summary> | ||
public enum MessageReferenceType | ||
{ | ||
/// <summary> | ||
/// A standard reference used by replies. | ||
/// </summary> | ||
Reply = 0, | ||
|
||
/// <summary> | ||
/// A reference used to point to a message at a point in time. | ||
/// </summary> | ||
Forward = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Disqord.Serialization.Json; | ||
|
||
namespace Disqord.Models; | ||
|
||
public class MessageSnapshotJsonModel : JsonModel | ||
{ | ||
[JsonProperty("message")] | ||
public MessageJsonModel Message = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters