12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package discordgo
- import (
- "fmt"
- "strings"
- )
- type Message struct {
- ID string `json:"id"`
- Author *User `json:"author"`
- Content string `json:"content"`
- Attachments []*Attachment `json:"attachments"`
- Tts bool `json:"tts"`
- Embeds []*Embed `json:"embeds"`
- Timestamp string `json:"timestamp"`
- MentionEveryone bool `json:"mention_everyone"`
- EditedTimestamp string `json:"edited_timestamp"`
- Mentions []*User `json:"mentions"`
- ChannelID string `json:"channel_id"`
- }
- type Attachment struct {
- }
- type Embed struct {
- }
- func (m *Message) ContentWithMentionsReplaced() string {
- content := m.Content
- for _, user := range m.Mentions {
- content = strings.Replace(content, fmt.Sprintf("<@%s>", user.ID),
- fmt.Sprintf("@%s", user.Username), -1)
- }
- return content
- }
|