mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-10 13:33:14 +00:00
Discord: add Message.ReferencedMessage and InlinedReplyMessage
This commit is contained in:
parent
e3c85094a7
commit
eb118dc1d6
|
@ -6,12 +6,19 @@ import (
|
|||
"github.com/diamondburned/arikawa/v2/utils/json/enum"
|
||||
)
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object
|
||||
type Message struct {
|
||||
ID MessageID `json:"id,string"`
|
||||
Type MessageType `json:"type"`
|
||||
ChannelID ChannelID `json:"channel_id,string"`
|
||||
GuildID GuildID `json:"guild_id,string,omitempty"`
|
||||
// ID is the id of the message.
|
||||
ID MessageID `json:"id,string"`
|
||||
// Type is the type of message.
|
||||
Type MessageType `json:"type"`
|
||||
// ChannelID is the id of the channel the message was sent in.
|
||||
ChannelID ChannelID `json:"channel_id,string"`
|
||||
// GuildID is the id of the guild the message was sent in.
|
||||
GuildID GuildID `json:"guild_id,string,omitempty"`
|
||||
|
||||
// Author is the author of the message.
|
||||
//
|
||||
// The author object follows the structure of the user object, but is only
|
||||
// a valid user in the case where the message is generated by a user or bot
|
||||
// user. If the message is generated by a webhook, the author object
|
||||
|
@ -20,38 +27,72 @@ type Message struct {
|
|||
// message object.
|
||||
Author User `json:"author"`
|
||||
|
||||
// Content contains the contents of the message.
|
||||
Content string `json:"content"`
|
||||
|
||||
Timestamp Timestamp `json:"timestamp,omitempty"`
|
||||
// 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"`
|
||||
|
||||
TTS bool `json:"tts"`
|
||||
// TTS specifies whether the was a TTS message.
|
||||
TTS bool `json:"tts"`
|
||||
// Pinned specifies whether the message is pinned.
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// 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"`
|
||||
// MentionEveryone specifies whether the message mentions everyone.
|
||||
MentionEveryone bool `json:"mention_everyone"`
|
||||
|
||||
MentionRoleIDs []RoleID `json:"mention_roles"`
|
||||
MentionEveryone bool `json:"mention_everyone"`
|
||||
|
||||
// MentionRoleIDs contains the ids of the roles specifically mentioned in
|
||||
// the message.
|
||||
MentionRoleIDs []RoleID `json:"mention_roles"`
|
||||
// MentionChannels are the channels specifically mentioned in the message.
|
||||
//
|
||||
// Not all channel mentions in a message will appear in mention_channels.
|
||||
// Only textual channels that are visible to everyone in a lurkable guild
|
||||
// will ever be included. Only crossposted messages (via Channel Following)
|
||||
// currently include mention_channels at all. If no mentions in the message
|
||||
// meet these requirements, the slice will be empty.
|
||||
MentionChannels []ChannelMention `json:"mention_channels,omitempty"`
|
||||
|
||||
// Attachments contains any attached files.
|
||||
Attachments []Attachment `json:"attachments"`
|
||||
Embeds []Embed `json:"embeds"`
|
||||
// Embeds contains any embedded content.
|
||||
Embeds []Embed `json:"embeds"`
|
||||
|
||||
Reactions []Reaction `json:"reactions,omitempty"`
|
||||
|
||||
// Used for validating a message was sent
|
||||
Nonce string `json:"nonce,omitempty"`
|
||||
|
||||
WebhookID WebhookID `json:"webhook_id,string,omitempty"`
|
||||
Activity *MessageActivity `json:"activity,omitempty"`
|
||||
// WebhookID contains the ID of the webhook, if the message was generated
|
||||
// by a webhook.
|
||||
WebhookID WebhookID `json:"webhook_id,string,omitempty"`
|
||||
|
||||
// Activity is sent with Rich Presence-related chat embeds.
|
||||
Activity *MessageActivity `json:"activity,omitempty"`
|
||||
// Application is sent with Rich Presence-related chat embeds.
|
||||
Application *MessageApplication `json:"application,omitempty"`
|
||||
Reference *MessageReference `json:"message_reference,omitempty"`
|
||||
Flags MessageFlags `json:"flags"`
|
||||
|
||||
// Reference is the reference data sent with crossposted messages and
|
||||
// inline replies.
|
||||
Reference *MessageReference `json:"message_reference,omitempty"`
|
||||
// ReferencedMessage is the message that was replied to. If not present and
|
||||
// the type is InlinedReplyMessage, the backend couldn't fetch the
|
||||
// replied-to message. If null, the message was deleted. If present and
|
||||
// non-null, it is a message object
|
||||
ReferencedMessage *Message `json:"referenced_message,omitempty"`
|
||||
|
||||
// Flags are the MessageFlags.
|
||||
Flags MessageFlags `json:"flags"`
|
||||
}
|
||||
|
||||
// URL generates a Discord client URL to the message. If the message doesn't
|
||||
|
@ -70,6 +111,7 @@ func (m Message) URL() string {
|
|||
|
||||
type MessageType uint8
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
||||
const (
|
||||
DefaultMessage MessageType = iota
|
||||
RecipientAddMessage
|
||||
|
@ -86,24 +128,46 @@ const (
|
|||
ChannelFollowAddMessage
|
||||
GuildDiscoveryDisqualifiedMessage
|
||||
GuildDiscoveryRequalifiedMessage
|
||||
_
|
||||
_
|
||||
_
|
||||
_
|
||||
InlinedReplyMessage
|
||||
)
|
||||
|
||||
type MessageFlags enum.Enum
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
||||
var (
|
||||
NullMessage MessageFlags = enum.Null
|
||||
CrosspostedMessage MessageFlags = 1
|
||||
MessageIsCrosspost MessageFlags = 2
|
||||
SuppressEmbeds MessageFlags = 4
|
||||
// NullMessage is the JSON null value of MessageFlags.
|
||||
NullMessage MessageFlags = enum.Null
|
||||
// CrosspostedMessage specifies whether the message has been published to
|
||||
// subscribed channels (via Channel Following).
|
||||
CrosspostedMessage MessageFlags = 1
|
||||
// MessageIsCrosspost specifies whether the message originated from a
|
||||
// message in another channel (via Channel Following).
|
||||
MessageIsCrosspost MessageFlags = 2
|
||||
// SuppressEmbeds specifies whether to not include any embeds when
|
||||
// serializing the message.
|
||||
SuppressEmbeds MessageFlags = 4
|
||||
// SourceMessageDeleted specifies whether the source message for the
|
||||
// crosspost has been deleted (via Channel Following).
|
||||
SourceMessageDeleted MessageFlags = 8
|
||||
UrgentMessage MessageFlags = 16
|
||||
// UrgentMessage specifies whether the message came from the urgent message
|
||||
// system.
|
||||
UrgentMessage MessageFlags = 16
|
||||
)
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#channel-mention-object
|
||||
type ChannelMention struct {
|
||||
ChannelID ChannelID `json:"id,string"`
|
||||
GuildID GuildID `json:"guild_id,string"`
|
||||
// ChannelID is the ID of the channel.
|
||||
ChannelID ChannelID `json:"id"`
|
||||
// GuildID is the ID of the guild containing the channel.
|
||||
GuildID GuildID `json:"guild_id"`
|
||||
// ChannelType is the type of channel.
|
||||
ChannelType ChannelType `json:"type"`
|
||||
ChannelName string `json:"name"`
|
||||
// ChannelName is the name of the channel.
|
||||
ChannelName string `json:"name"`
|
||||
}
|
||||
|
||||
type GuildUser struct {
|
||||
|
@ -113,15 +177,17 @@ type GuildUser struct {
|
|||
|
||||
//
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure
|
||||
type MessageActivity struct {
|
||||
// Type is the type of message activity.
|
||||
Type MessageActivityType `json:"type"`
|
||||
|
||||
// From a Rich Presence event
|
||||
// PartyID is the party_id from a Rich Presence event.
|
||||
PartyID string `json:"party_id,omitempty"`
|
||||
}
|
||||
|
||||
type MessageActivityType uint8
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
|
||||
const (
|
||||
JoinMessage MessageActivityType = iota + 1
|
||||
SpectateMessage
|
||||
|
@ -131,43 +197,62 @@ const (
|
|||
|
||||
//
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
|
||||
type MessageApplication struct {
|
||||
ID AppID `json:"id,string"`
|
||||
CoverID string `json:"cover_image,omitempty"`
|
||||
// ID is the id of the application.
|
||||
ID AppID `json:"id"`
|
||||
// CoverID is the id of the embed's image asset.
|
||||
CoverID string `json:"cover_image,omitempty"`
|
||||
// Description is the application's description.
|
||||
Description string `json:"description"`
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
// Icon is the id of the application's icon.
|
||||
Icon string `json:"icon"`
|
||||
// Name is the name of the application.
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
||||
type MessageReference struct {
|
||||
ChannelID ChannelID `json:"channel_id,string"`
|
||||
|
||||
// Field might not be provided
|
||||
MessageID MessageID `json:"message_id,string,omitempty"`
|
||||
GuildID GuildID `json:"guild_id,string,omitempty"`
|
||||
// MessageID is the id of the originating message.
|
||||
MessageID MessageID `json:"message_id,omitempty"`
|
||||
// ChannelID is the id of the originating message's channel.
|
||||
ChannelID ChannelID `json:"channel_id,omitempty"`
|
||||
// GuildID is the id of the originating message's guild.
|
||||
GuildID GuildID `json:"guild_id,omitempty"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#attachment-object
|
||||
type Attachment struct {
|
||||
ID AttachmentID `json:"id,string"`
|
||||
Filename string `json:"filename"`
|
||||
Size uint64 `json:"size"`
|
||||
// ID is the attachment id.
|
||||
ID AttachmentID `json:"id,string"`
|
||||
// Filename is the name of file attached.
|
||||
Filename string `json:"filename"`
|
||||
// Size is the size of file in bytes.
|
||||
Size uint64 `json:"size"`
|
||||
|
||||
URL URL `json:"url"`
|
||||
// URL is the source url of file.
|
||||
URL URL `json:"url"`
|
||||
// Proxy is the a proxied url of file.
|
||||
Proxy URL `json:"proxy_url"`
|
||||
|
||||
// Only if Image
|
||||
// Height is the height of the file, if it is an image.
|
||||
Height uint `json:"height,omitempty"`
|
||||
Width uint `json:"width,omitempty"`
|
||||
// Width is the width of the file, if it is an image.
|
||||
Width uint `json:"width,omitempty"`
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#reaction-object
|
||||
type Reaction struct {
|
||||
Count int `json:"count"`
|
||||
Me bool `json:"me"` // for current user
|
||||
// Count is the amount of times the emoji has been used to react.
|
||||
Count int `json:"count"`
|
||||
// Me specifies whether the current user reacted using this emoji.
|
||||
Me bool `json:"me"`
|
||||
// Emoji contains emoji information.
|
||||
Emoji Emoji `json:"emoji"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue