From 8b18bf4dc7c9aef86fd3c8f706a11b28d064c859 Mon Sep 17 00:00:00 2001 From: David G Date: Fri, 29 Jul 2022 17:45:18 +0200 Subject: [PATCH] Allow setting bool properties of ChannelEdit to false (#1199) Setting e.g. ChannelEdit.Archived = false is currently not possible as go will treat a false as empty and will omit the property from the JSON object. --- examples/threads/main.go | 6 ++++-- structs.go | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/threads/main.go b/examples/threads/main.go index 9b6179184..5ea5f8c9c 100644 --- a/examples/threads/main.go +++ b/examples/threads/main.go @@ -48,9 +48,11 @@ func main() { games[m.ChannelID] = time.Now() <-time.After(timeout) if time.Since(games[m.ChannelID]) >= timeout { + archived := true + locked := true _, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{ - Archived: true, - Locked: true, + Archived: &archived, + Locked: &locked, }) if err != nil { panic(err) diff --git a/structs.go b/structs.go index 3ea4b15fd..781dff173 100644 --- a/structs.go +++ b/structs.go @@ -360,7 +360,7 @@ func (c *Channel) IsThread() bool { type ChannelEdit struct { Name string `json:"name,omitempty"` Topic string `json:"topic,omitempty"` - NSFW bool `json:"nsfw,omitempty"` + NSFW *bool `json:"nsfw,omitempty"` Position int `json:"position"` Bitrate int `json:"bitrate,omitempty"` UserLimit int `json:"user_limit,omitempty"` @@ -370,10 +370,10 @@ type ChannelEdit struct { // NOTE: threads only - Archived bool `json:"archived,omitempty"` - AutoArchiveDuration int `json:"auto_archive_duration,omitempty"` - Locked bool `json:"locked,bool"` - Invitable bool `json:"invitable,omitempty"` + Archived *bool `json:"archived,omitempty"` + AutoArchiveDuration int `json:"auto_archive_duration,omitempty"` + Locked *bool `json:"locked,omitempty"` + Invitable *bool `json:"invitable,omitempty"` } // A ChannelFollow holds data returned after following a news channel