mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 09:32:50 +00:00
use permissions from database - updated bot-scripts
This commit is contained in:
@@ -3,6 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
@@ -20,9 +21,15 @@ type User struct {
|
||||
Verified bool `json:"verified"`
|
||||
MFAEnabled bool `json:"mfa_enabled"`
|
||||
Bot bool `json:"bot"`
|
||||
Permissions *int `gorm:"default:1;not null" json:"permissions"`
|
||||
}
|
||||
|
||||
// UserSave -
|
||||
func UserSave(conn *gorm.DB, u *User) error {
|
||||
return conn.Save(u).Error
|
||||
var userCopy User
|
||||
copier.Copy(&userCopy, u)
|
||||
// insert or update user
|
||||
// need to make copy of assign object because it must mess
|
||||
// with the actual object in FirstOrCreate method
|
||||
return conn.Where(&User{ID: u.ID}).Assign(userCopy).FirstOrCreate(u).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user