added create date calculator for server.
This commit is contained in:
18
server.go
18
server.go
@@ -1,6 +1,10 @@
|
||||
package revoltgo
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/oklog/ulid/v2"
|
||||
)
|
||||
|
||||
// Server struct.
|
||||
type Server struct {
|
||||
@@ -35,3 +39,15 @@ type SystemMessages struct {
|
||||
UserKicked string `json:"user_kicker"`
|
||||
UserBanned string `json:"user_banned"`
|
||||
}
|
||||
|
||||
// Calculate creation date and edit the struct.
|
||||
func (c *Server) CalculateCreationDate() error {
|
||||
ulid, err := ulid.Parse(c.Id)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.CreatedAt = time.UnixMilli(int64(ulid.Time()))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user