2020-01-02 19:53:08 +00:00
|
|
|
package discord
|
|
|
|
|
2020-07-17 18:33:57 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2020-11-21 16:35:19 +00:00
|
|
|
"strings"
|
2021-05-20 22:47:44 +00:00
|
|
|
"time"
|
2020-07-17 18:33:57 +00:00
|
|
|
|
2021-06-02 02:53:19 +00:00
|
|
|
"github.com/diamondburned/arikawa/v3/utils/json/enum"
|
2020-07-17 18:33:57 +00:00
|
|
|
)
|
2020-05-11 22:06:19 +00:00
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object
|
2020-01-02 19:53:08 +00:00
|
|
|
type Message struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// ID is the id of the message.
|
2020-11-22 14:48:36 +00:00
|
|
|
ID MessageID `json:"id"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// ChannelID is the id of the channel the message was sent in.
|
2020-11-22 14:48:36 +00:00
|
|
|
ChannelID ChannelID `json:"channel_id"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// GuildID is the id of the guild the message was sent in.
|
2020-11-22 14:48:36 +00:00
|
|
|
GuildID GuildID `json:"guild_id,omitempty"`
|
2020-01-02 19:53:08 +00:00
|
|
|
|
2020-11-22 14:48:36 +00:00
|
|
|
// Type is the type of message.
|
|
|
|
Type MessageType `json:"type"`
|
2020-01-02 19:53:08 +00:00
|
|
|
|
2020-11-22 14:48:36 +00:00
|
|
|
// Flags are the MessageFlags.
|
|
|
|
Flags MessageFlags `json:"flags"`
|
2020-01-02 19:53:08 +00:00
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// TTS specifies whether the was a TTS message.
|
|
|
|
TTS bool `json:"tts"`
|
|
|
|
// Pinned specifies whether the message is pinned.
|
2020-01-02 19:53:08 +00:00
|
|
|
Pinned bool `json:"pinned"`
|
|
|
|
|
2020-11-22 14:48:36 +00:00
|
|
|
// MentionEveryone specifies whether the message mentions everyone.
|
|
|
|
MentionEveryone bool `json:"mention_everyone"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Mentions contains the users specifically mentioned in the message.
|
|
|
|
//
|
2020-01-02 19:53:08 +00:00
|
|
|
// 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"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2020-01-02 19:53:08 +00:00
|
|
|
// Not all channel mentions in a message will appear in mention_channels.
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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.
|
2020-01-02 19:53:08 +00:00
|
|
|
MentionChannels []ChannelMention `json:"mention_channels,omitempty"`
|
|
|
|
|
2020-11-22 14:48:36 +00:00
|
|
|
// 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
|
|
|
|
// corresponds to the webhook's id, username, and avatar. You can tell if a
|
|
|
|
// message is generated by a webhook by checking for the webhook_id on the
|
|
|
|
// message object.
|
|
|
|
Author User `json:"author"`
|
|
|
|
|
|
|
|
// Content contains the contents of the message.
|
|
|
|
Content string `json:"content"`
|
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// Attachments contains any attached files.
|
2020-01-02 19:53:08 +00:00
|
|
|
Attachments []Attachment `json:"attachments"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Embeds contains any embedded content.
|
|
|
|
Embeds []Embed `json:"embeds"`
|
2021-05-30 04:28:37 +00:00
|
|
|
// Reactions contains any reactions to the message.
|
2020-02-10 15:12:47 +00:00
|
|
|
Reactions []Reaction `json:"reactions,omitempty"`
|
2021-05-30 04:28:37 +00:00
|
|
|
// Components contains any attached components.
|
2021-10-10 22:44:31 +00:00
|
|
|
Components ContainerComponents `json:"components,omitempty"`
|
2020-01-02 19:53:08 +00:00
|
|
|
|
|
|
|
// Used for validating a message was sent
|
|
|
|
Nonce string `json:"nonce,omitempty"`
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// WebhookID contains the ID of the webhook, if the message was generated
|
|
|
|
// by a webhook.
|
2020-11-22 14:48:36 +00:00
|
|
|
WebhookID WebhookID `json:"webhook_id,omitempty"`
|
2020-11-03 18:03:16 +00:00
|
|
|
|
|
|
|
// Activity is sent with Rich Presence-related chat embeds.
|
|
|
|
Activity *MessageActivity `json:"activity,omitempty"`
|
|
|
|
// Application is sent with Rich Presence-related chat embeds.
|
2020-01-02 19:53:08 +00:00
|
|
|
Application *MessageApplication `json:"application,omitempty"`
|
2020-11-03 18:03:16 +00:00
|
|
|
|
2022-09-21 17:30:12 +00:00
|
|
|
// ApplicationID contains the ID of the application, if this message was
|
|
|
|
// generated by an interaction or an application-owned webhook.
|
|
|
|
ApplicationID AppID `json:"application_id,omitempty"`
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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"`
|
|
|
|
|
2022-05-24 14:45:52 +00:00
|
|
|
// Interaction is the interaction that the message is in response to.
|
|
|
|
// This is only present if the message is in response to an interaction.
|
|
|
|
Interaction *MessageInteraction `json:"interaction,omitempty"`
|
|
|
|
|
2022-01-29 11:38:10 +00:00
|
|
|
// Stickers contains the sticker "items" sent with the message.
|
|
|
|
Stickers []StickerItem `json:"sticker_items,omitempty"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 05:49:34 +00:00
|
|
|
// URL generates a Discord client URL to the message. If the message doesn't
|
|
|
|
// have a GuildID, it will generate a URL with the guild "@me".
|
|
|
|
func (m Message) URL() string {
|
2020-07-17 18:33:57 +00:00
|
|
|
var guildID = "@me"
|
2020-07-29 20:10:17 +00:00
|
|
|
if m.GuildID.IsValid() {
|
2020-07-17 18:33:57 +00:00
|
|
|
guildID = m.GuildID.String()
|
2020-01-24 05:49:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 18:33:57 +00:00
|
|
|
return fmt.Sprintf(
|
|
|
|
"https://discord.com/channels/%s/%s/%s",
|
|
|
|
guildID, m.ChannelID.String(), m.ID.String(),
|
|
|
|
)
|
2020-01-24 05:49:34 +00:00
|
|
|
}
|
|
|
|
|
2020-01-02 19:53:08 +00:00
|
|
|
type MessageType uint8
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
2020-01-02 19:53:08 +00:00
|
|
|
const (
|
2021-05-21 06:12:53 +00:00
|
|
|
DefaultMessage MessageType = iota
|
|
|
|
RecipientAddMessage
|
|
|
|
RecipientRemoveMessage
|
|
|
|
CallMessage
|
|
|
|
ChannelNameChangeMessage
|
|
|
|
ChannelIconChangeMessage
|
|
|
|
ChannelPinnedMessage
|
|
|
|
GuildMemberJoinMessage
|
|
|
|
NitroBoostMessage
|
|
|
|
NitroTier1Message
|
|
|
|
NitroTier2Message
|
|
|
|
NitroTier3Message
|
|
|
|
ChannelFollowAddMessage
|
|
|
|
_
|
|
|
|
GuildDiscoveryDisqualifiedMessage
|
|
|
|
GuildDiscoveryRequalifiedMessage
|
|
|
|
GuildDiscoveryGracePeriodInitialWarning
|
|
|
|
GuildDiscoveryGracePeriodFinalWarning
|
2021-08-08 20:19:15 +00:00
|
|
|
// ThreadCreatedMessage is a new message sent to the parent GuildText
|
|
|
|
// channel, used to inform users that a thread has been created. It is
|
|
|
|
// currently only sent in one case: when a GuildPublicThread is created
|
|
|
|
// from an older message (older is still TBD, but is currently set to a
|
|
|
|
// very small value). The message contains a message reference with the
|
|
|
|
// GuildID and ChannelID of the thread. The content of the message is the
|
|
|
|
// name of the thread.
|
|
|
|
ThreadCreatedMessage
|
2021-05-21 06:12:53 +00:00
|
|
|
InlinedReplyMessage
|
2021-09-24 04:37:50 +00:00
|
|
|
ChatInputCommandMessage
|
2021-08-08 20:19:15 +00:00
|
|
|
// ThreadStarterMessage is a new message sent as the first message in
|
|
|
|
// threads that are started from an existing message in the parent channel.
|
|
|
|
// It only contains a message reference field that points to the message
|
|
|
|
// from which the thread was started.
|
|
|
|
ThreadStarterMessage
|
|
|
|
GuildInviteReminderMessage
|
2021-09-24 04:37:50 +00:00
|
|
|
ContextMenuCommand
|
2023-01-02 07:28:43 +00:00
|
|
|
AutoModerationActionMessage
|
2023-02-16 09:24:01 +00:00
|
|
|
RoleSubscriptionPurchaseMessage
|
|
|
|
InteractionPremiumUpsellMessage
|
|
|
|
|
|
|
|
StageStartMessage
|
|
|
|
StageEndMessage
|
|
|
|
StageSpeakerMessage
|
|
|
|
_
|
|
|
|
StageTopicMessage
|
|
|
|
|
|
|
|
GuildApplicationPremiumSubscriptionMessage
|
2020-01-02 19:53:08 +00:00
|
|
|
)
|
|
|
|
|
2020-05-11 22:06:19 +00:00
|
|
|
type MessageFlags enum.Enum
|
2020-01-02 19:53:08 +00:00
|
|
|
|
2021-05-21 06:12:53 +00:00
|
|
|
// NullMessage is the JSON null value of MessageFlags.
|
|
|
|
const NullMessage MessageFlags = enum.Null
|
|
|
|
|
2021-05-21 23:40:11 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-flags
|
2021-05-21 06:12:53 +00:00
|
|
|
const (
|
2020-11-03 18:03:16 +00:00
|
|
|
// CrosspostedMessage specifies whether the message has been published to
|
|
|
|
// subscribed channels (via Channel Following).
|
2021-05-21 06:12:53 +00:00
|
|
|
CrosspostedMessage MessageFlags = 1 << iota
|
2020-11-03 18:03:16 +00:00
|
|
|
// MessageIsCrosspost specifies whether the message originated from a
|
|
|
|
// message in another channel (via Channel Following).
|
2021-05-21 06:12:53 +00:00
|
|
|
MessageIsCrosspost
|
2020-11-03 18:03:16 +00:00
|
|
|
// SuppressEmbeds specifies whether to not include any embeds when
|
|
|
|
// serializing the message.
|
2021-05-21 06:12:53 +00:00
|
|
|
SuppressEmbeds
|
2020-11-03 18:03:16 +00:00
|
|
|
// SourceMessageDeleted specifies whether the source message for the
|
|
|
|
// crosspost has been deleted (via Channel Following).
|
2021-05-21 06:12:53 +00:00
|
|
|
SourceMessageDeleted
|
2020-11-03 18:03:16 +00:00
|
|
|
// UrgentMessage specifies whether the message came from the urgent message
|
|
|
|
// system.
|
2021-05-21 06:12:53 +00:00
|
|
|
UrgentMessage
|
|
|
|
// MessageHasThread specifies whether the message has an associated thread
|
|
|
|
// with the same id as the message
|
|
|
|
MessageHasThread
|
|
|
|
// EphemeralMessage specifies whether the message is only visible to
|
|
|
|
// the user who invoked the Interaction
|
|
|
|
EphemeralMessage
|
|
|
|
// MessageLoading specifies whether the message is an Interaction Response
|
|
|
|
// and the bot is "thinking"
|
|
|
|
MessageLoading
|
2023-02-11 09:32:59 +00:00
|
|
|
// TODO: add FailedToMentionSomeRolesInThread
|
|
|
|
|
|
|
|
// SuppressNotifications specifies whether the message will not trigger push and desktop notifications.
|
|
|
|
SuppressNotifications = 1 << 12
|
2020-01-02 19:53:08 +00:00
|
|
|
)
|
|
|
|
|
2022-01-29 11:38:10 +00:00
|
|
|
// StickerItem contains partial data of a Sticker.
|
|
|
|
//
|
|
|
|
// https://discord.com/developers/docs/resources/sticker#sticker-item-object
|
|
|
|
type StickerItem struct {
|
|
|
|
// ID is the ID of the sticker.
|
|
|
|
ID StickerID `json:"id"`
|
|
|
|
// Name is the name of the sticker.
|
|
|
|
Name string `json:"name"`
|
|
|
|
// FormatType is the type of sticker format.
|
|
|
|
FormatType StickerFormatType `json:"format_type"`
|
|
|
|
}
|
|
|
|
|
2022-05-08 23:03:57 +00:00
|
|
|
// StickerURLWithType returns the URL to the emoji's image.
|
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG
|
|
|
|
func (s StickerItem) StickerURLWithType(t ImageType) string {
|
|
|
|
return "https://cdn.discordapp.com/stickers/" + t.format(s.ID.String())
|
|
|
|
}
|
|
|
|
|
2020-11-21 16:35:19 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
|
|
|
|
type Sticker struct {
|
|
|
|
// ID is the ID of the sticker.
|
|
|
|
ID StickerID `json:"id"`
|
|
|
|
// PackID is the ID of the pack the sticker is from.
|
2021-08-02 23:16:06 +00:00
|
|
|
PackID StickerPackID `json:"pack_id,omitempty"`
|
2020-11-21 16:35:19 +00:00
|
|
|
// Name is the name of the sticker.
|
|
|
|
Name string `json:"name"`
|
|
|
|
// Description is the description of the sticker.
|
|
|
|
Description string `json:"description"`
|
2020-12-20 00:08:28 +00:00
|
|
|
// Tags is a comma-delimited list of tags for the sticker. To get the list
|
|
|
|
// as a slice, use TagList.
|
2021-08-02 23:16:06 +00:00
|
|
|
Tags string `json:"tags"`
|
|
|
|
// Type is the type of sticker.
|
|
|
|
Type StickerType `json:"type"`
|
2020-11-21 16:35:19 +00:00
|
|
|
// FormatType is the type of sticker format.
|
|
|
|
FormatType StickerFormatType `json:"format_type"`
|
2021-08-02 23:16:06 +00:00
|
|
|
// Available specifies whether this guild sticker can be used, may be false due to loss of Server Boosts.
|
|
|
|
Available bool `json:"available,omitempty"`
|
|
|
|
// GuildID is the id of the guild that owns this sticker.
|
|
|
|
GuildID GuildID `json:"guild_id,omitempty"`
|
|
|
|
// User is the user that uploaded the guild sticker
|
|
|
|
User *User `json:"user,omitempty"`
|
|
|
|
// SortValue is the standard sticker's sort order within its pack.
|
|
|
|
SortValue *int `json:"sort_value,omitempty"`
|
2020-11-21 16:35:19 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 22:47:44 +00:00
|
|
|
// CreatedAt returns a time object representing when the sticker was created.
|
|
|
|
func (s Sticker) CreatedAt() time.Time {
|
|
|
|
return s.ID.Time()
|
|
|
|
}
|
|
|
|
|
|
|
|
// PackCreatedAt returns a time object representing when the sticker's pack
|
|
|
|
// was created.
|
|
|
|
func (s Sticker) PackCreatedAt() time.Time {
|
|
|
|
return s.PackID.Time()
|
|
|
|
}
|
|
|
|
|
2022-01-29 11:38:10 +00:00
|
|
|
// TagList splits the sticker tags into a slice of strings. Each tag will have
|
|
|
|
// its trailing space trimmed.
|
2020-12-20 00:08:28 +00:00
|
|
|
func (s Sticker) TagList() []string {
|
2022-01-29 11:38:10 +00:00
|
|
|
tags := strings.Split(s.Tags, ",")
|
|
|
|
for i := range tags {
|
|
|
|
tags[i] = strings.TrimSpace(tags[i])
|
|
|
|
}
|
|
|
|
return tags
|
2020-11-21 16:35:19 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 23:03:57 +00:00
|
|
|
// StickerURLWithType returns the URL to the emoji's image.
|
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG
|
|
|
|
func (s Sticker) StickerURLWithType(t ImageType) string {
|
|
|
|
return "https://cdn.discordapp.com/stickers/" + t.format(s.ID.String())
|
|
|
|
}
|
|
|
|
|
2021-08-02 23:16:06 +00:00
|
|
|
type StickerType int
|
|
|
|
|
|
|
|
// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
|
|
|
|
const (
|
|
|
|
// StandardSticker is an official sticker in a pack, part of Nitro or in a removed purchasable pack.
|
|
|
|
StandardSticker StickerType = iota + 1
|
|
|
|
// GuildSticker is a sticker uploaded to a boosted guild for the guild's members.
|
|
|
|
GuildSticker
|
|
|
|
)
|
|
|
|
|
2020-11-21 16:35:19 +00:00
|
|
|
type StickerFormatType uint8
|
|
|
|
|
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types
|
|
|
|
const (
|
|
|
|
StickerFormatPNG = 1
|
|
|
|
StickerFormatAPNG = 2
|
|
|
|
StickerFormatLottie = 3
|
|
|
|
)
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#channel-mention-object
|
2020-01-02 19:53:08 +00:00
|
|
|
type ChannelMention struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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.
|
2020-01-02 19:53:08 +00:00
|
|
|
ChannelType ChannelType `json:"type"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// ChannelName is the name of the channel.
|
|
|
|
ChannelName string `json:"name"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GuildUser struct {
|
|
|
|
User
|
2020-01-04 04:19:24 +00:00
|
|
|
Member *Member `json:"member,omitempty"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure
|
2020-01-02 19:53:08 +00:00
|
|
|
type MessageActivity struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// Type is the type of message activity.
|
2020-01-02 19:53:08 +00:00
|
|
|
Type MessageActivityType `json:"type"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// PartyID is the party_id from a Rich Presence event.
|
2020-01-02 19:53:08 +00:00
|
|
|
PartyID string `json:"party_id,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type MessageActivityType uint8
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
|
2020-01-02 19:53:08 +00:00
|
|
|
const (
|
|
|
|
JoinMessage MessageActivityType = iota + 1
|
|
|
|
SpectateMessage
|
|
|
|
ListenMessage
|
|
|
|
JoinRequestMessage
|
|
|
|
)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
|
2020-01-02 19:53:08 +00:00
|
|
|
type MessageApplication struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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.
|
2020-07-21 20:27:59 +00:00
|
|
|
Description string `json:"description"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Icon is the id of the application's icon.
|
|
|
|
Icon string `json:"icon"`
|
|
|
|
// Name is the name of the application.
|
|
|
|
Name string `json:"name"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 22:47:44 +00:00
|
|
|
// CreatedAt returns a time object representing when the message application
|
|
|
|
// was created.
|
|
|
|
func (m MessageApplication) CreatedAt() time.Time {
|
|
|
|
return m.ID.Time()
|
|
|
|
}
|
|
|
|
|
2020-11-03 18:24:23 +00:00
|
|
|
// MessageReference is used in four situations:
|
|
|
|
//
|
2023-01-02 07:28:43 +00:00
|
|
|
// # Crosspost messages
|
2020-11-03 18:24:23 +00:00
|
|
|
//
|
|
|
|
// Messages that originated from another channel (IS_CROSSPOST flag). These
|
|
|
|
// messages have all three fields, with data of the original message that was
|
|
|
|
// crossposted.
|
|
|
|
//
|
2023-01-02 07:28:43 +00:00
|
|
|
// # Channel Follow Add messages
|
2020-11-03 18:24:23 +00:00
|
|
|
//
|
|
|
|
// Automatic messages sent when a channel is followed into the current channel
|
|
|
|
// (type 12). These messages have the ChannelID and GuildID fields, with data
|
|
|
|
// of the followed announcement channel.
|
|
|
|
//
|
2023-01-02 07:28:43 +00:00
|
|
|
// # Pin messages
|
2020-11-03 18:24:23 +00:00
|
|
|
//
|
|
|
|
// Automatic messages sent when a message is pinned (type 6). These messages
|
|
|
|
// have MessageID and ChannelID, and GuildID if it is in a guild, with data
|
|
|
|
// of the message that was pinned.
|
|
|
|
//
|
2023-01-02 07:28:43 +00:00
|
|
|
// # Replies
|
2020-11-03 18:24:23 +00:00
|
|
|
//
|
|
|
|
// Messages replying to a previous message (type 19). These messages have
|
|
|
|
// MessageID, and ChannelID, and GuildID if it is in a guild, with data of the
|
|
|
|
// message that was replied to. The ChannelID and GuildID will be the
|
|
|
|
// same as the reply.
|
|
|
|
//
|
|
|
|
// Replies are created by including a message_reference when sending a message.
|
|
|
|
// When sending, only MessageID is required.
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
2020-01-02 19:53:08 +00:00
|
|
|
type MessageReference struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// 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"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2022-05-24 14:45:12 +00:00
|
|
|
// https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure
|
|
|
|
type MessageInteraction struct {
|
|
|
|
// ID is the id of the originating interaction.
|
|
|
|
ID InteractionID `json:"id"`
|
|
|
|
// Type is the type of the originating interaction.
|
|
|
|
Type InteractionDataType `json:"type"`
|
|
|
|
// Name is the name of the application command that was invoked with the
|
|
|
|
// originating interaction.
|
|
|
|
Name string `json:"name"`
|
|
|
|
// User is the user who invoked the originating interaction.
|
|
|
|
User User `json:"user"`
|
|
|
|
// Member is the member who invoked the originating interaction in
|
|
|
|
// the guild.
|
|
|
|
Member *Member `json:"member,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#attachment-object
|
2020-01-02 19:53:08 +00:00
|
|
|
type Attachment struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// ID is the attachment id.
|
2020-11-22 14:48:36 +00:00
|
|
|
ID AttachmentID `json:"id"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Filename is the name of file attached.
|
|
|
|
Filename string `json:"filename"`
|
2022-09-28 22:22:29 +00:00
|
|
|
// Description is the attachment's description. It is a maximum of 1024
|
|
|
|
// characters long.
|
|
|
|
Description string `json:"description,omitempty"`
|
2021-08-12 01:16:50 +00:00
|
|
|
// ContentType is the media type of file.
|
2021-08-12 18:45:48 +00:00
|
|
|
ContentType string `json:"content_type,omitempty"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Size is the size of file in bytes.
|
|
|
|
Size uint64 `json:"size"`
|
|
|
|
|
|
|
|
// URL is the source url of file.
|
|
|
|
URL URL `json:"url"`
|
|
|
|
// Proxy is the a proxied url of file.
|
2020-01-02 19:53:08 +00:00
|
|
|
Proxy URL `json:"proxy_url"`
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// Height is the height of the file, if it is an image.
|
2020-01-02 19:53:08 +00:00
|
|
|
Height uint `json:"height,omitempty"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Width is the width of the file, if it is an image.
|
|
|
|
Width uint `json:"width,omitempty"`
|
2021-09-24 04:37:50 +00:00
|
|
|
// Ephemeral is whether this attachment is ephemeral. Ephemeral attachments
|
|
|
|
// will automatically be removed after a set period of time. Ephemeral
|
|
|
|
// attachments on messages are guaranteed to be available as long as
|
|
|
|
// the message itself exists.
|
|
|
|
Ephemeral bool `json:"ephemeral,omitempty"`
|
2020-01-02 19:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2020-11-03 18:03:16 +00:00
|
|
|
// https://discord.com/developers/docs/resources/channel#reaction-object
|
2020-01-02 19:53:08 +00:00
|
|
|
type Reaction struct {
|
2020-11-03 18:03:16 +00:00
|
|
|
// Count is the amount of times the emoji has been used to react.
|
|
|
|
Count int `json:"count"`
|
2023-09-01 09:18:24 +00:00
|
|
|
// CountDetails contains burst (super) and normal reactions count.
|
|
|
|
CountDetails ReactionCountDetails `json:"count_details"`
|
2020-11-03 18:03:16 +00:00
|
|
|
// Me specifies whether the current user reacted using this emoji.
|
|
|
|
Me bool `json:"me"`
|
|
|
|
// Emoji contains emoji information.
|
2020-01-02 19:53:08 +00:00
|
|
|
Emoji Emoji `json:"emoji"`
|
|
|
|
}
|
2023-09-01 09:18:24 +00:00
|
|
|
|
|
|
|
// https://discord.com/developers/docs/resources/channel#reaction-count-details-object
|
|
|
|
type ReactionCountDetails struct {
|
|
|
|
// Burst is the count of super reactions.
|
|
|
|
Burst int `json:"burst"`
|
|
|
|
// Normal is the count of normal reactions.
|
|
|
|
Normal int `json:"normal"`
|
|
|
|
}
|