2021-10-10 22:44:31 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
types=(
|
|
|
|
SubcommandOption
|
|
|
|
SubcommandGroupOption
|
|
|
|
StringOption
|
|
|
|
IntegerOption
|
|
|
|
BooleanOption
|
|
|
|
UserOption
|
|
|
|
ChannelOption
|
|
|
|
RoleOption
|
|
|
|
MentionableOption
|
2021-12-29 19:10:59 +00:00
|
|
|
NumberOption
|
2021-10-10 22:44:31 +00:00
|
|
|
)
|
|
|
|
|
2021-11-25 23:02:24 +00:00
|
|
|
for ((i = 0; i < ${#types[@]}; i++)); {
|
|
|
|
recv=$(head -c1 <<< "${types[$i]}" | tr "[:upper:]" "[:lower:]")
|
2021-10-10 22:44:31 +00:00
|
|
|
|
|
|
|
cat<<EOF
|
|
|
|
// MarshalJSON marshals ${types[$i]} to JSON with the "type" field.
|
2021-11-25 23:02:24 +00:00
|
|
|
func (${recv} *${types[$i]}) MarshalJSON() ([]byte, error) {
|
2021-10-10 22:44:31 +00:00
|
|
|
type raw ${types[$i]}
|
|
|
|
return json.Marshal(struct {
|
|
|
|
Type CommandOptionType \`json:"type"\`
|
|
|
|
*raw
|
|
|
|
}{
|
2021-11-25 23:02:24 +00:00
|
|
|
Type: ${recv}.Type(),
|
|
|
|
raw: (*raw)(${recv}),
|
2021-10-10 22:44:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|