1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-09 16:42:48 +00:00
Files
go-discord-bot/server/logger/model.go

60 lines
1.7 KiB
Go

package logger
import (
"time"
"github.com/mgerb/go-discord-bot/server/db"
)
// Message - discord message
type Message struct {
ID string `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
ChannelID string `json:"channel_id"`
Content string `json:"content"`
Timestamp time.Time `json:"timestamp"`
EditedTimestamp time.Time `json:"edited_timestamp"`
MentionRoles string `json:"mention_roles"`
Tts bool `json:"tts"`
MentionEveryone bool `json:"mention_everyone"`
User User `json:"user"`
UserID string `json:"user_id"`
Attachments []Attachment `json:"attachments"`
}
// Save -
func (m *Message) Save() error {
return db.GetConn().Save(m).Error
}
// Attachment - discord message attachment
type Attachment struct {
MessageID string `gorm:"primary_key" 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"`
}
// User -
type User struct {
ID string `gorm:"primary_key" json:"id"`
Email string `json:"email"`
Username string `json:"username"`
Avatar string `json:"avatar"`
Discriminator string `json:"discriminator"`
Token string `json:"token"`
Verified bool `json:"verified"`
MFAEnabled bool `json:"mfa_enabled"`
Bot bool `json:"bot"`
}
// Save -
func (u *User) Save() error {
return db.GetConn().Save(u).Error
}