mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-01 04:24:19 +00:00
discord: Add message_snapshot support (#453)
* Add new type field https://discord.com/developers/docs/resources/message#message-reference-structure * Update with changes * Add message_snapshot * fixup * fixup * Convert Message to MessageSnapshotMessage
This commit is contained in:
parent
6f5a53063f
commit
9e83b0ef90
|
@ -23,6 +23,9 @@ type Message struct {
|
||||||
// Flags are the MessageFlags.
|
// Flags are the MessageFlags.
|
||||||
Flags MessageFlags `json:"flags"`
|
Flags MessageFlags `json:"flags"`
|
||||||
|
|
||||||
|
// The message associated with the message_reference. This is a minimal subset of fields in a message (e.g. author is excluded.)
|
||||||
|
MessageSnapshots []MessageSnapshot `json:"message_snapshots,omitempty"`
|
||||||
|
|
||||||
// TTS specifies whether the was a TTS message.
|
// TTS specifies whether the was a TTS message.
|
||||||
TTS bool `json:"tts"`
|
TTS bool `json:"tts"`
|
||||||
// Pinned specifies whether the message is pinned.
|
// Pinned specifies whether the message is pinned.
|
||||||
|
@ -365,6 +368,65 @@ func (m MessageApplication) CreatedAt() time.Time {
|
||||||
return m.ID.Time()
|
return m.ID.Time()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/message#message-snapshot-object
|
||||||
|
type MessageSnapshotMessage struct {
|
||||||
|
// Type is the type of message.
|
||||||
|
Type MessageType `json:"type"`
|
||||||
|
|
||||||
|
// Content contains the contents of the message.
|
||||||
|
Content string `json:"content"`
|
||||||
|
|
||||||
|
// Embeds contains any embedded content.
|
||||||
|
Embeds []Embed `json:"embeds"`
|
||||||
|
|
||||||
|
// Attachments contains any attached files.
|
||||||
|
Attachments []Attachment `json:"attachments"`
|
||||||
|
|
||||||
|
// Timestamp specifies when the message was sent
|
||||||
|
Timestamp Timestamp `json:"timestamp,omitempty"`
|
||||||
|
|
||||||
|
// EditedTimestamp specifies when this message was edited.
|
||||||
|
//
|
||||||
|
// IsValid() will return false, if the messages hasn't been edited.
|
||||||
|
EditedTimestamp Timestamp `json:"edited_timestamp,omitempty"`
|
||||||
|
|
||||||
|
// Flags are the MessageFlags.
|
||||||
|
Flags MessageFlags `json:"flags"`
|
||||||
|
|
||||||
|
// Mentions contains the users specifically mentioned in the message.
|
||||||
|
//
|
||||||
|
// The user objects in the mentions array will only have the partial
|
||||||
|
// member field present in MESSAGE_CREATE and MESSAGE_UPDATE events from
|
||||||
|
// text-based guild channels.
|
||||||
|
Mentions []GuildUser `json:"mentions"`
|
||||||
|
|
||||||
|
// MentionRoleIDs contains the ids of the roles specifically mentioned in
|
||||||
|
// the message.
|
||||||
|
MentionRoleIDs []RoleID `json:"mention_roles"`
|
||||||
|
|
||||||
|
// Stickers contains the sticker "items" sent with the message.
|
||||||
|
Stickers []StickerItem `json:"sticker_items,omitempty"`
|
||||||
|
|
||||||
|
// Components contains any attached components.
|
||||||
|
Components ContainerComponents `json:"components,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/message#message-snapshot-object
|
||||||
|
type MessageSnapshot struct {
|
||||||
|
// The embedded partial message object
|
||||||
|
Message *MessageSnapshotMessage `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// A standard reference used by replies.
|
||||||
|
MessageReferenceTypeDefault MessageReferenceType = iota
|
||||||
|
// Reference used to point to a message at a point in time.
|
||||||
|
MessageReferenceTypeForward
|
||||||
|
)
|
||||||
|
|
||||||
|
// Type of message reference
|
||||||
|
type MessageReferenceType int
|
||||||
|
|
||||||
// MessageReference is used in four situations:
|
// MessageReference is used in four situations:
|
||||||
//
|
//
|
||||||
// # Crosspost messages
|
// # Crosspost messages
|
||||||
|
@ -396,6 +458,9 @@ func (m MessageApplication) CreatedAt() time.Time {
|
||||||
// When sending, only MessageID is required.
|
// When sending, only MessageID is required.
|
||||||
// https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
// https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
||||||
type MessageReference struct {
|
type MessageReference struct {
|
||||||
|
// If type is unset, DEFAULT can be assumed in order to match the behaviour before message reference
|
||||||
|
// had types. In future API versions this will become a required field.
|
||||||
|
Type MessageReferenceType `json:"type"`
|
||||||
// MessageID is the id of the originating message.
|
// MessageID is the id of the originating message.
|
||||||
MessageID MessageID `json:"message_id,omitempty"`
|
MessageID MessageID `json:"message_id,omitempty"`
|
||||||
// ChannelID is the id of the originating message's channel.
|
// ChannelID is the id of the originating message's channel.
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
github.com/diamondburned/arikawa/v3 v3.0.0-rc.6/go.mod h1:5jBSNnp82Z/EhsKa6Wk9FsOqSxfVkNZDTDBPOj47LpY=
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/sys v0.0.0-20211001092434-39dca1131b70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
|
||||||
|
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
|
|
Loading…
Reference in a new issue