mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-14 02:42:51 +00:00
33 lines
588 B
Bash
Executable file
33 lines
588 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
types=(
|
|
SubcommandOption
|
|
SubcommandGroupOption
|
|
StringOption
|
|
IntegerOption
|
|
BooleanOption
|
|
UserOption
|
|
ChannelOption
|
|
RoleOption
|
|
MentionableOption
|
|
)
|
|
|
|
for ((i = 0; i < ${#types[@]}; i++)); {
|
|
recv=$(head -c1 <<< "${types[$i]}" | tr "[:upper:]" "[:lower:]")
|
|
|
|
cat<<EOF
|
|
// MarshalJSON marshals ${types[$i]} to JSON with the "type" field.
|
|
func (${recv} *${types[$i]}) MarshalJSON() ([]byte, error) {
|
|
type raw ${types[$i]}
|
|
return json.Marshal(struct {
|
|
Type CommandOptionType \`json:"type"\`
|
|
*raw
|
|
}{
|
|
Type: ${recv}.Type(),
|
|
raw: (*raw)(${recv}),
|
|
})
|
|
}
|
|
|
|
EOF
|
|
}
|