message

package
v0.0.0-...-8fd61c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: BSD-3-Clause Imports: 11 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MentionEveryone = AllowedMention{
	Parse: []AllowedMentionType{EVERYONE},
}

Helper

Functions

func BuildTimestamp

func BuildTimestamp(timestamp time.Time, style TimestampStyle) string

func BuildTimestampFromUnixSecs

func BuildTimestampFromUnixSecs(timestamp int64, style TimestampStyle) string

func SumFlags

func SumFlags(flags ...MessageFlag) (sum uint)

Types

type AllowedMention

type AllowedMention struct {
	Parse       []AllowedMentionType    `json:"parse,omitempty"`
	Roles       utils.Uint64StringSlice `json:"roles,omitempty"`
	Users       utils.Uint64StringSlice `json:"users,omitempty"`
	RepliedUser bool                    `json:"replied_user"`
}

type AllowedMentionType

type AllowedMentionType string
const (
	EVERYONE AllowedMentionType = "everyone"
	USERS    AllowedMentionType = "users"
	ROLES    AllowedMentionType = "roles"
)

type ChannelMention

type ChannelMention struct {
	Id      uint64              `json:"id,string"`
	GuildId uint64              `json:"guild_id,string"`
	Type    channel.ChannelType `json:"type"`
	Name    string              `json:"name"` // channel name
}

type Message

type Message struct {
	Id                       uint64                  `json:"id,string"`
	ChannelId                uint64                  `json:"channel_id,string"`
	GuildId                  uint64                  `json:"guild_id,string"`
	Author                   user.User               `json:"author"`
	Member                   member.Member           `json:"member"`
	Content                  string                  `json:"content"`
	Timestamp                time.Time               `json:"timestamp"`
	EditedTimestamp          *time.Time              `json:"edited_timestamp,omitempty"`
	Tts                      bool                    `json:"tts"`
	MentionEveryone          bool                    `json:"mention_everyone"`
	Mentions                 []MessageMentionedUser  `json:"mentions,omitempty"` // 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
	MentionRoles             utils.Uint64StringSlice `json:"mention_roles"`
	VisibleMentionedChannels []ChannelMention        `json:"mention_channels,omitempty"` // 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, this field will not be sent.
	Attachments              []channel.Attachment    `json:"attachments,omitempty"`
	Embeds                   []embed.Embed           `json:"embeds,omitempty"`
	Reactions                []Reaction              `json:"reactions,omitempty"`
	Nonce                    interface{}             `json:"nonce,omitempty"`
	Pinned                   bool                    `json:"pinned"`
	WebhookId                uint64                  `json:"webhook_id,string"` // if the message is generated by a webhook, this is the webhook's id
	Type                     MessageType             `json:"message_type"`
	Activity                 MessageActivity         `json:"activity"`
	Application              MessageApplication      `json:"application"`
	MessageReference         MessageReference        `json:"message_reference"` // reference data sent with crossposted messages
	Flags                    int                     `json:"flags"`
	ReferencedMessage        *MessageReference       `json:"referenced_message,omitempty"`
	Components               []component.Component   `json:"components,omitempty"`
}

func (*Message) ChannelMentions

func (m *Message) ChannelMentions() []uint64

type MessageActivity

type MessageActivity struct {
	Type    MessageActivityType `json:"type"`
	PartyId string              `json:"party_id"`
}

type MessageActivityType

type MessageActivityType int
const (
	MessageActivityJoin MessageActivityType = iota
	MessageActivitySpectate
	MessageActivityListen
	MessageActivityJoinRequest
)

type MessageApplication

type MessageApplication struct {
	Id          uint64 `json:",string"`
	CoverImage  string
	Description string
	Icon        string
	Name        string
}

type MessageFlag

type MessageFlag uint
const (
	FlagCrossposted MessageFlag = 1 << iota
	FlagIsCrosspost
	FlagSupressEmbeds
	FlagSourceMessageDeleted
	FlagUrgent

	FlagEphemeral
	FlagLoading
)

type MessageMentionedUser

type MessageMentionedUser struct {
	user.User
	Member member.Member
}

Mentions is an array of users with partial member

type MessageReference

type MessageReference struct {
	MessageId       uint64 `json:"message_id,string"`
	ChannelId       uint64 `json:"channel_id,string"`
	GuildId         uint64 `json:"guild_id,string"`
	FailIfNotExists bool   `json:"fail_if_not_exists"`
}

type MessageType

type MessageType int
const (
	MessageTypeDefault MessageType = iota
	MessageTypeRecipientAdd
	MessageTypeRecipientRemove
	MessageTypeCall
	MessageTypeChannelNameChange
	MessageTypeChannelIconChange
	MessageTypeChannelPinnedMessage
	MessageTypeGuildMemberJoin
	MessageTypeUserPremiumGuildSubscription
	MessageTypeUserPremiumGuildSubscriptionTier1
	MessageTypeUserPremiumGuildSubscriptionTier2
	MessageTypeUserPremiumGuildSubscriptionTier3
	MessageTypeChannelFollowAdd
	MessageTypeGuildDiscoveryDisqualified
	MessageTypeGuildDiscoveryRequalified
	MessageTypeGuildDiscoveryGracePeriodInitialWarning
	MessageTypeGuildDiscoveryGracePeriodFinalWarning
	MessageTypeThreadCreated
	MessageTypeReply
	MessageTypeApplicationCommand
	MessageTypeThreadStarterMessage
	MessageTypeGuildInviteReminder
)

type Reaction

type Reaction struct {
	Count int
	Me    bool
	Emoji emoji.Emoji
}

type TimestampStyle

type TimestampStyle string
const (
	TimestampStyleShortTime     TimestampStyle = "s"
	TimestampStyleLongTime      TimestampStyle = "T"
	TimestampStyleShortDate     TimestampStyle = "d"
	TimestampStyleLongDate      TimestampStyle = "D"
	TimestampStyleShortDateTime TimestampStyle = "f"
	TimestampStyleLongDateTime  TimestampStyle = "F"
	TimestampStyleRelativeTime  TimestampStyle = "R"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL