1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 18:53:30 +00:00
arikawa/utils/cmd/gensnowflake/template.tmpl
2022-03-15 13:37:35 -07:00

40 lines
1.5 KiB
Cheetah

// Code generated by gensnowflake. DO NOT EDIT.
package {{ .Package }}
{{ $dot := "" }}
{{ if .ImportDiscord }}
{{ $dot = "discord." }}
import "github.com/diamondburned/arikawa/v3/discord"
{{ end }}
import "time"
{{ range .Snowflakes }}
// {{ .TypeName }} is the snowflake type for a {{ .TypeName }}.
type {{.TypeName}} {{$dot}}Snowflake
// Null{{.TypeName}} gets encoded into a null. This is used for optional and nullable snowflake fields.
const Null{{.TypeName}} = {{.TypeName}}({{$dot}}NullSnowflake)
func (s {{.TypeName}}) MarshalJSON() ([]byte, error) { return {{$dot}}Snowflake(s).MarshalJSON() }
func (s *{{.TypeName}}) UnmarshalJSON(v []byte) error { return (*{{$dot}}Snowflake)(s).UnmarshalJSON(v) }
// String returns the ID, or nothing if the snowflake isn't valid.
func (s {{.TypeName}}) String() string { return {{$dot}}Snowflake(s).String() }
// IsValid returns whether or not the snowflake is valid.
func (s {{.TypeName}}) IsValid() bool { return {{$dot}}Snowflake(s).IsValid() }
// IsNull returns whether or not the snowflake is null. This method is rarely
// ever useful; most people should use IsValid instead.
func (s {{.TypeName}}) IsNull() bool { return {{$dot}}Snowflake(s).IsNull() }
func (s {{.TypeName}}) Time() time.Time { return {{$dot}}Snowflake(s).Time() }
func (s {{.TypeName}}) Worker() uint8 { return {{$dot}}Snowflake(s).Worker() }
func (s {{.TypeName}}) PID() uint8 { return {{$dot}}Snowflake(s).PID() }
func (s {{.TypeName}}) Increment() uint16 { return {{$dot}}Snowflake(s).Increment() }
{{ end }}