forked from pothtonswer/discordmuffin
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.
This commit is contained in:
parent
039e6855ed
commit
8b18bf4dc7
2 changed files with 9 additions and 7 deletions
|
@ -48,9 +48,11 @@ func main() {
|
||||||
games[m.ChannelID] = time.Now()
|
games[m.ChannelID] = time.Now()
|
||||||
<-time.After(timeout)
|
<-time.After(timeout)
|
||||||
if time.Since(games[m.ChannelID]) >= timeout {
|
if time.Since(games[m.ChannelID]) >= timeout {
|
||||||
|
archived := true
|
||||||
|
locked := true
|
||||||
_, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{
|
_, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{
|
||||||
Archived: true,
|
Archived: &archived,
|
||||||
Locked: true,
|
Locked: &locked,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
10
structs.go
10
structs.go
|
@ -360,7 +360,7 @@ func (c *Channel) IsThread() bool {
|
||||||
type ChannelEdit struct {
|
type ChannelEdit struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Topic string `json:"topic,omitempty"`
|
Topic string `json:"topic,omitempty"`
|
||||||
NSFW bool `json:"nsfw,omitempty"`
|
NSFW *bool `json:"nsfw,omitempty"`
|
||||||
Position int `json:"position"`
|
Position int `json:"position"`
|
||||||
Bitrate int `json:"bitrate,omitempty"`
|
Bitrate int `json:"bitrate,omitempty"`
|
||||||
UserLimit int `json:"user_limit,omitempty"`
|
UserLimit int `json:"user_limit,omitempty"`
|
||||||
|
@ -370,10 +370,10 @@ type ChannelEdit struct {
|
||||||
|
|
||||||
// NOTE: threads only
|
// NOTE: threads only
|
||||||
|
|
||||||
Archived bool `json:"archived,omitempty"`
|
Archived *bool `json:"archived,omitempty"`
|
||||||
AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
|
AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
|
||||||
Locked bool `json:"locked,bool"`
|
Locked *bool `json:"locked,omitempty"`
|
||||||
Invitable bool `json:"invitable,omitempty"`
|
Invitable *bool `json:"invitable,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A ChannelFollow holds data returned after following a news channel
|
// A ChannelFollow holds data returned after following a news channel
|
||||||
|
|
Loading…
Reference in a new issue