123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package discordgo
- import (
- "fmt"
- "regexp"
- )
- type Message struct {
- ID string `json:"id"`
- ChannelID string `json:"channel_id"`
- Content string `json:"content"`
- Timestamp Timestamp `json:"timestamp"`
- EditedTimestamp Timestamp `json:"edited_timestamp"`
- MentionRoles []string `json:"mention_roles"`
- Tts bool `json:"tts"`
- MentionEveryone bool `json:"mention_everyone"`
- Author *User `json:"author"`
- Attachments []*MessageAttachment `json:"attachments"`
- Embeds []*MessageEmbed `json:"embeds"`
- Mentions []*User `json:"mentions"`
- Reactions []*MessageReactions `json:"reactions"`
- }
- type MessageAttachment struct {
- ID string `json:"id"`
- URL string `json:"url"`
- ProxyURL string `json:"proxy_url"`
- Filename string `json:"filename"`
- Width int `json:"width"`
- Height int `json:"height"`
- Size int `json:"size"`
- }
- type MessageEmbedFooter struct {
- Text string `json:"text,omitempty"`
- IconURL string `json:"icon_url,omitempty"`
- ProxyIconURL string `json:"proxy_icon_url,omitempty"`
- }
- type MessageEmbedImage struct {
- URL string `json:"url,omitempty"`
- ProxyURL string `json:"proxy_url,omitempty"`
- Width int `json:"width,omitempty"`
- Height int `json:"height,omitempty"`
- }
- type MessageEmbedThumbnail struct {
- URL string `json:"url,omitempty"`
- ProxyURL string `json:"proxy_url,omitempty"`
- Width int `json:"width,omitempty"`
- Height int `json:"height,omitempty"`
- }
- type MessageEmbedVideo struct {
- URL string `json:"url,omitempty"`
- ProxyURL string `json:"proxy_url,omitempty"`
- Width int `json:"width,omitempty"`
- Height int `json:"height,omitempty"`
- }
- type MessageEmbedProvider struct {
- URL string `json:"url,omitempty"`
- Name string `json:"name,omitempty"`
- }
- type MessageEmbedAuthor struct {
- URL string `json:"url,omitempty"`
- Name string `json:"name,omitempty"`
- IconURL string `json:"icon_url,omitempty"`
- ProxyIconURL string `json:"proxy_icon_url,omitempty"`
- }
- type MessageEmbedField struct {
- Name string `json:"name,omitempty"`
- Value string `json:"value,omitempty"`
- Inline bool `json:"inline,omitempty"`
- }
- type MessageEmbed struct {
- URL string `json:"url,omitempty"`
- Type string `json:"type,omitempty"`
- Title string `json:"title,omitempty"`
- Description string `json:"description,omitempty"`
- Timestamp string `json:"timestamp,omitempty"`
- Color int `json:"color,omitempty"`
- Footer *MessageEmbedFooter `json:"footer,omitempty"`
- Image *MessageEmbedImage `json:"image,omitempty"`
- Thumbnail *MessageEmbedThumbnail `json:"thumbnail,omitempty"`
- Video *MessageEmbedVideo `json:"video,omitempty"`
- Provider *MessageEmbedProvider `json:"provider,omitempty"`
- Author *MessageEmbedAuthor `json:"author,omitempty"`
- Fields []*MessageEmbedField `json:"fields,omitempty"`
- }
- type MessageReactions struct {
- Count int `json:"count"`
- Me bool `json:"me"`
- Emoji *Emoji `json:"emoji"`
- }
- func (m *Message) ContentWithMentionsReplaced() string {
- if m.Mentions == nil {
- return m.Content
- }
- content := m.Content
- for _, user := range m.Mentions {
- content = regexp.MustCompile(fmt.Sprintf("<@!?(%s)>", user.ID)).ReplaceAllString(content, "@"+user.Username)
- }
- return content
- }
|