go-serverapi/ban.go

31 lines
713 B
Go
Raw Normal View History

package serverapi
import (
"fmt"
"time"
)
// Ban is a Minecraft ban
type Ban struct {
Target string `json:"target"`
Source string `jso:"source"`
Reason string `json:"reason"`
Created int64 `json:"created"`
Expiration int64 `json:"expiration"`
}
// CreatedTime is Created converted to a time.Time
func (b *Ban) CreatedTime() time.Time {
return time.Unix(b.Created/1000, 0)
}
// ExpirationTime is Expiration converted to a time.Time
func (b *Ban) ExpirationTime() time.Time {
return time.Unix(b.Expiration/1000, 0)
}
// Bans gets a list of Ban from a ServerAPI instance
2020-08-13 20:41:14 +00:00
func (c *Client) Bans() (bans Ban, err error) {
return bans, c.json(fmt.Sprintf("%s/bans", c.Endpoint), &bans)
}