diff --git a/server.go b/server.go index aebf489..60a68c4 100644 --- a/server.go +++ b/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 +}