discord.v
discord.v copied to clipboard
Optional fields rewrite
At the moment, optional fields in structures are not implemented in vlang, but as far as I understand this is a matter of time. We can try to implement our own through generics:
struct None {}
type OptError = string | None
struct Opt<T> {
value T
error OptError = None{}
}
struct MessageModify {
text Opt<string>
}
editQuery := MessageModify{Opt<string>{value: 'Hello there!'})
// Then in rest method check every field error and serialize
Options will replace almost all fields in already written structures
or do nothing yet and wait for implementation in language
Now we are just waiting for the implementation of optional fields in structures