From c14e68ac7721e70d2beb078e048a44f81d4d0ea6 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 29 Dec 2021 11:10:59 -0800 Subject: [PATCH] discord: Add missing NumberOption MarshalJSON --- discord/command.go | 12 ++++++++++++ utils/generate-option-marshalers.sh | 1 + 2 files changed, 13 insertions(+) diff --git a/discord/command.go b/discord/command.go index 5c77ae5..c2de315 100644 --- a/discord/command.go +++ b/discord/command.go @@ -708,3 +708,15 @@ func (m *MentionableOption) MarshalJSON() ([]byte, error) { raw: (*raw)(m), }) } + +// MarshalJSON marshals NumberOption to JSON with the "type" field. +func (n *NumberOption) MarshalJSON() ([]byte, error) { + type raw NumberOption + return json.Marshal(struct { + Type CommandOptionType `json:"type"` + *raw + }{ + Type: n.Type(), + raw: (*raw)(n), + }) +} diff --git a/utils/generate-option-marshalers.sh b/utils/generate-option-marshalers.sh index 06cfd54..8b8f168 100755 --- a/utils/generate-option-marshalers.sh +++ b/utils/generate-option-marshalers.sh @@ -10,6 +10,7 @@ types=( ChannelOption RoleOption MentionableOption + NumberOption ) for ((i = 0; i < ${#types[@]}; i++)); {