diff --git a/discord/guild_const.go b/discord/guild_const.go index 0eb8d0c..bb87376 100644 --- a/discord/guild_const.go +++ b/discord/guild_const.go @@ -1,5 +1,7 @@ package discord +import "github.com/diamondburned/arikawa/utils/json/option" + // Guild.MaxPresences is 5000 when it's 0. const DefaultMaxPresences = 5000 @@ -49,38 +51,83 @@ const ( Banner GuildFeature = "BANNER" ) -type ExplicitFilter uint8 +// ExplicitFilter is the explicit content filter level of a guild. +type ExplicitFilter option.Enum -const ( - NoContentFilter ExplicitFilter = iota - MembersWithoutRoles - AllMembers +var ( + // NullExplicitFilter serialized to JSON null. + // This should only be used on nullable fields. + NullExplicitFilter ExplicitFilter = option.EnumNull + // NoContentFilter disables content filtering for the guild. + NoContentFilter ExplicitFilter = 0 + // MembersWithoutRoles filters only members without roles. + MembersWithoutRoles ExplicitFilter = 1 + // AllMembers enables content filtering for all members. + AllMembers ExplicitFilter = 2 ) -type Notification uint8 +func (f *ExplicitFilter) UnmarshalJSON(b []byte) error { + i, err := option.EnumFromJSON(b) + *f = ExplicitFilter(i) -const ( - AllMessages Notification = iota - OnlyMentions + return err +} + +func (f ExplicitFilter) MarshalJSON() ([]byte, error) { return option.EnumToJSON(option.Enum(f)), nil } + +// Notification is the default message notification level of a guild. +type Notification option.Enum + +var ( + // NullNotification serialized to JSON null. + // This should only be used on nullable fields. + NullNotification Notification = option.EnumNull + // AllMessages sends notifications for all messages. + AllMessages Notification = 0 + // OnlyMentions sends notifications only on mention. + OnlyMentions Notification = 1 ) -type Verification uint8 +func (n *Notification) UnmarshalJSON(b []byte) error { + i, err := option.EnumFromJSON(b) + *n = Notification(i) -const ( - NoVerification Verification = iota + return err +} + +func (n Notification) MarshalJSON() ([]byte, error) { return option.EnumToJSON(option.Enum(n)), nil } + +// Verification is the verification level required for a guild. +type Verification option.Enum + +var ( + // NullVerification serialized to JSON null. + // This should only be used on nullable fields. + NullVerification Verification = option.EnumNull + // NoVerification required no verification. + NoVerification Verification = 0 // LowVerification requires a verified email - LowVerification + LowVerification Verification = 1 // MediumVerification requires the user be registered for at least 5 // minutes. - MediumVerification + MediumVerification Verification = 2 // HighVerification requires the member be in the server for more than 10 // minutes. - HighVerification + HighVerification Verification = 3 // VeryHighVerification requires the member to have a verified phone // number. - VeryHighVerification + VeryHighVerification Verification = 4 ) +func (v *Verification) UnmarshalJSON(b []byte) error { + i, err := option.EnumFromJSON(b) + *v = Verification(i) + + return err +} + +func (v Verification) MarshalJSON() ([]byte, error) { return option.EnumToJSON(option.Enum(v)), nil } + // Service is used for guild integrations and user connections. type Service string