mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 10:43:30 +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
|
|
}
|