util.go 430 B

123456789101112131415161718192021
  1. package discordgo
  2. import (
  3. "strconv"
  4. "time"
  5. )
  6. // SnowflakeTimestamp returns the creation time of a Snowflake ID relative to the creation of Discord.
  7. func SnowflakeTimestamp(ID string) (t time.Time, err error) {
  8. i, err := strconv.ParseInt(ID, 10, 64)
  9. if err != nil {
  10. return
  11. }
  12. timestamp := (i >> 22) + 1420070400000
  13. t = time.Unix(timestamp/1000, 0)
  14. return
  15. }
  16. func MakeIntent(intents Intent) *Intent {
  17. return &intents
  18. }