diff --git a/api/channel.go b/api/channel.go index e101217..ebf2c36 100644 --- a/api/channel.go +++ b/api/channel.go @@ -27,8 +27,8 @@ type CreateChannelData struct { UserRateLimit discord.Seconds `json:"rate_limit_per_user,omitempty"` - NSFW bool `json:"nsfw"` - Position int `json:"position,omitempty"` + NSFW bool `json:"nsfw,omitempty"` + Position option.Int `json:"position,omitempty"` Permissions []discord.Overwrite `json:"permission_overwrites,omitempty"` CategoryID discord.Snowflake `json:"parent_id,string,omitempty"` @@ -68,9 +68,11 @@ func (c *Client) Channel(channelID discord.Snowflake) (*discord.Channel, error) type ModifyChannelData struct { // All types - Name string `json:"name,omitempty"` - Position option.Int `json:"position,omitempty"` - Permissions []discord.Overwrite `json:"permission_overwrites,omitempty"` + Name string `json:"name,omitempty"` + // Type allows conversions between text and news channels. + Type *discord.ChannelType `json:"type,omitempty"` + Position option.Int `json:"position,omitempty"` + Permissions *[]discord.Overwrite `json:"permission_overwrites,omitempty"` // Text only Topic option.String `json:"topic,omitempty"` diff --git a/api/guild.go b/api/guild.go index 933595f..0d67394 100644 --- a/api/guild.go +++ b/api/guild.go @@ -143,7 +143,7 @@ type ModifyGuildData struct { ExplicitFilter *discord.ExplicitFilter `json:"explicit_content_filter,omitempty"` // nullable AFKChannelID discord.Snowflake `json:"afk_channel_id,string,omitempty"` - AFKTimeout discord.Seconds `json:"afk_timeout,omitempty"` + AFKTimeout option.Seconds `json:"afk_timeout,omitempty"` OwnerID discord.Snowflake `json:"owner_id,omitempty"` diff --git a/api/role.go b/api/role.go index 92383a3..b2c0955 100644 --- a/api/role.go +++ b/api/role.go @@ -3,6 +3,7 @@ package api import ( "github.com/diamondburned/arikawa/discord" "github.com/diamondburned/arikawa/utils/httputil" + "github.com/diamondburned/arikawa/utils/json/option" ) func (c *Client) AddRole(guildID, userID, roleID discord.Snowflake) error { @@ -23,7 +24,7 @@ func (c *Client) Roles(guildID discord.Snowflake) ([]discord.Role, error) { EndpointGuilds+guildID.String()+"/roles") } -type AnyRoleData struct { +type CreateRoleData struct { Name string `json:"name,omitempty"` // "new role" Color discord.Color `json:"color,omitempty"` // 0 Hoist bool `json:"hoist,omitempty"` // false (show role separately) @@ -32,7 +33,7 @@ type AnyRoleData struct { Permissions discord.Permissions `json:"permissions,omitempty"` // @everyone } -func (c *Client) CreateRole(guildID discord.Snowflake, data AnyRoleData) (*discord.Role, error) { +func (c *Client) CreateRole(guildID discord.Snowflake, data CreateRoleData) (*discord.Role, error) { var role *discord.Role return role, c.RequestJSON( &role, "POST", @@ -60,9 +61,18 @@ func (c *Client) MoveRole( ) } +type ModifyRoleData struct { + Name string `json:"name,omitempty"` // "new role" + Color option.Color `json:"color,omitempty"` // 0 + Hoist option.Bool `json:"hoist,omitempty"` // false (show role separately) + + Mentionable option.Bool `json:"mentionable,omitempty"` // false + Permissions discord.Permissions `json:"permissions,omitempty"` // @everyone +} + func (c *Client) ModifyRole( guildID, roleID discord.Snowflake, - data AnyRoleData) (*discord.Role, error) { + data ModifyRoleData) (*discord.Role, error) { var role *discord.Role return role, c.RequestJSON( diff --git a/api/user.go b/api/user.go index 3fb4792..ef8eebb 100644 --- a/api/user.go +++ b/api/user.go @@ -23,7 +23,7 @@ func (c *Client) Me() (*discord.User, error) { type ModifySelfData struct { Username string `json:"username,omitempty"` - Avatar Image `json:"image,omitempty"` + Avatar *Image `json:"image,omitempty"` } func (c *Client) ModifyMe(data ModifySelfData) (*discord.User, error) { diff --git a/discord/auditlog.go b/discord/auditlog.go index 52d67b4..e79d6bf 100644 --- a/discord/auditlog.go +++ b/discord/auditlog.go @@ -1,8 +1,9 @@ package discord import ( - "github.com/diamondburned/arikawa/utils/json" "github.com/pkg/errors" + + "github.com/diamondburned/arikawa/utils/json" ) type AuditLog struct { diff --git a/utils/json/option/bool.go b/utils/json/option/bool.go index 92396f0..8e3482f 100644 --- a/utils/json/option/bool.go +++ b/utils/json/option/bool.go @@ -9,6 +9,4 @@ var ( ) // newBool creates a new Bool with the value of the passed bool. -func newBool(b bool) Bool { - return &b -} +func newBool(b bool) Bool { return &b } diff --git a/utils/json/option/number.go b/utils/json/option/number.go index f92e4f5..f8a5b18 100644 --- a/utils/json/option/number.go +++ b/utils/json/option/number.go @@ -1,25 +1,23 @@ package option -type ( - // Uint is the option type for unsigned integers (uint). - Uint *uint - // Int is the option type for integers (int). - Int *int -) +// ================================ Uint ================================ -var ( - // ZeroUint is a Uint with 0 as value. - ZeroUint = NewUint(0) - // ZeroInt is an Int with 0 as value. - ZeroInt = NewInt(0) -) +// Uint is the option type for unsigned integers (uint). +type Uint *uint + +// ZeroUint is a Uint with 0 as value. +var ZeroUint = NewUint(0) // NewUint creates a new Uint using the value of the passed uint. -func NewUint(u uint) Uint { - return &u -} +func NewUint(u uint) Uint { return &u } + +// ================================ Int ================================ + +// Int is the option type for integers (int). +type Int *int + +// ZeroInt is an Int with 0 as value. +var ZeroInt = NewInt(0) // NewInt creates a new Int using the value of the passed int. -func NewInt(i int) Int { - return &i -} +func NewInt(i int) Int { return &i } diff --git a/utils/json/option/string.go b/utils/json/option/string.go index b31217c..74ca0c6 100644 --- a/utils/json/option/string.go +++ b/utils/json/option/string.go @@ -7,6 +7,4 @@ type String *string var EmptyString = NewString("") // NewString creates a new String with the value of the passed string. -func NewString(s string) String { - return &s -} +func NewString(s string) String { return &s }