1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 10:43:30 +00:00

discord: Add {Min,Max} into {Integer,Number}Option

This commit is contained in:
diamondburned 2021-12-01 12:11:59 -08:00
parent 7af6e23569
commit 172d448e74
No known key found for this signature in database
GPG key ID: D78C4471CE776659
2 changed files with 20 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import (
"time"
"github.com/diamondburned/arikawa/v3/utils/json"
"github.com/diamondburned/arikawa/v3/utils/json/option"
"github.com/pkg/errors"
)
@ -399,8 +400,10 @@ func (i *IntegerOption) _val() {}
// IntegerChoice is a pair of string key to an integer.
type IntegerChoice struct {
Name string `json:"name"`
Value int `json:"value"`
Name string `json:"name"`
Value int `json:"value"`
Min option.Int `json:"min_value,omitempty"`
Max option.Int `json:"max_value,omitempty"`
}
// BooleanOption is a subcommand option that fits into a CommandOptionValue.
@ -491,8 +494,10 @@ func (n *NumberOption) _val() {}
// NumberChoice is a pair of string key to a float64 values.
type NumberChoice struct {
Name string `json:"name"`
Value float64 `json:"value"`
Name string `json:"name"`
Value float64 `json:"value"`
Min option.Float `json:"min_value,omitempty"`
Max option.Float `json:"max_value,omitempty"`
}
// NewCommand creates a new command.

View file

@ -24,6 +24,17 @@ var ZeroInt = NewInt(0)
// NewInt creates a new Int using the value of the passed int.
func NewInt(i int) Int { return &i }
// ================================ Float ================================
// Float is the option type for floating-point numbers (float64).
type Float *float64
// ZeroFloat is an Float with 0 as value.
var ZeroFloat = NewFloat(0)
// NewFloat creates a new Float using the value of the passed float64.
func NewFloat(i float64) Float { return &i }
// ================================ NullableUint ================================
// NullableUint is a nullable version of an unsigned integer (uint).