package db import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" ) type ReactRole struct { MessageID string EmojiID string RoleID string } var db *gorm.DB func init() { var err error db, err = gorm.Open("sqlite3", "bot.db") if err != nil { panic(err) } db.AutoMigrate(&ReactRole{}) } func Close() { db.Close() } func CreateReactRole(messageID, emojiID, roleID string) { db.Create(&ReactRole{ MessageID: messageID, EmojiID: emojiID, RoleID: roleID, }) } func GetReactRole(messageID, emojiID string) string { result := ReactRole{ MessageID: messageID, EmojiID: emojiID, } db.Where(&result).First(&result) return result.RoleID }