diff --git a/event/botcommand.go b/event/botcommand.go index 148f4db2..64d2cbf5 100644 --- a/event/botcommand.go +++ b/event/botcommand.go @@ -248,14 +248,14 @@ func (ps *MSC4391ParameterSchema) isValid(parent MSC4391SchemaType) bool { type MSC4391Parameter struct { Key string `json:"key"` - Type *MSC4391ParameterSchema `json:"type"` + Schema *MSC4391ParameterSchema `json:"schema"` Optional bool `json:"optional,omitempty"` Description *ExtensibleTextContainer `json:"description,omitempty"` DefaultValue any `json:"default_value,omitempty"` } func (p *MSC4391Parameter) IsValid() bool { - return p != nil && p.Key != "" && p.Type.IsValid() + return p != nil && p.Key != "" && p.Schema.IsValid() } func (p *MSC4391Parameter) GetDefaultValue() any { @@ -264,7 +264,7 @@ func (p *MSC4391Parameter) GetDefaultValue() any { } else if p == nil || p.Optional { return nil } - return p.Type.GetDefaultValue() + return p.Schema.GetDefaultValue() } type MSC4391BotCommandEventContent struct { diff --git a/event/botcommandparse.go b/event/botcommandparse.go index d01c8591..3fe0fe20 100644 --- a/event/botcommandparse.go +++ b/event/botcommandparse.go @@ -108,7 +108,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in origInput := input var nextVal string var wasQuoted bool - if param.Type.SchemaType == MSC4391SchemaTypeArray { + if param.Schema.SchemaType == MSC4391SchemaTypeArray { hasOpener := strings.HasPrefix(input, botArrayOpener) arrayClosed := false if hasOpener { @@ -135,7 +135,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in // For array arguments in the middle without the <> delimiters, stop after the first item arrayClosed = true } - parsedVal, err := param.Type.ParseString(nextVal) + parsedVal, err := param.Schema.ParseString(nextVal) if err == nil { collector = append(collector, parsedVal) } else if hasOpener || isLast { @@ -153,7 +153,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in nextVal += " " + input input = "" } - parsedVal, err := param.Type.ParseString(nextVal) + parsedVal, err := param.Schema.ParseString(nextVal) if err != nil { args[param.Key] = param.GetDefaultValue() // For optional parameters that fail to parse, restore the input and try passing it as the next parameter