ModifyGuildMember parameters are not nullable
Closed this issue · 5 comments
According to the discord developer documentation, all fields to ModifyGuildMember should be optional and nullable.
In this implementation, all fields are represented as Maybes and are therefore optional, but cannot be set to null.
In practice this means, that disconnecting a player from a voice channel or resetting their nickname is impossible.
Ah I see, though I'm not sure what the best exposed interface would be though, I guess something like
-- unsure on naming
data Maybe2 a = Just2 a | Nothing2 | Null2
data ModifyGuildMemberData = ModifyGuildMemberData
{ nick :: Maybe2 Text
, roles :: Maybe2 [Snowflake Role]
, mute :: Maybe2 Bool
, deaf :: Maybe2 Bool
, channelID :: Maybe2 (Snowflake VoiceChannel)
}
would work
Another option would be
data ModifyGuildMemberData = ModifyGuildMemberData
{ nick :: Maybe (Maybe Text)
, roles :: Maybe (Maybe [Snowflake Role])
, mute :: Maybe (Maybe Bool)
, deaf :: Maybe (Maybe Bool)
, channelID :: Maybe (Maybe (Snowflake VoiceChannel))
}
Not very elegant, but at least this would not have to invent a new type
it would mean the user would have to remember which layer omitted the key, and which one set to null.
I think a better named version of maybe2 would be
data OmittableField a = Provided a | Reset | Unchanged
Another way would be something wrapping Map Text Value
and providing functions like modifyGuildMemberAccessToken :: Text -> ModifyGuildMemberData
and giving monoid/semigroup instances for ModifyGuildMemberData
Great, thank you!