Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add min/max_length support for string option and min/max_value for integer #252

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

Birdie0
Copy link
Contributor

@Birdie0 Birdie0 commented Feb 2, 2024

Summary

Add missing supported arguments for string and integer option types

Added

  • string - add support for min_length & max_length arguments
  • integer - add support for min_value & max_value arguments
  • number - add documentation for min_value & max_value arguments

Example code

BOT.register_application_command(:test, "test command") do |cmd|
  cmd.integer("integer", "integer option", required: false, min_value: -5, max_value: 5)
  cmd.number("number", "number option", required: false, min_value: -3.14, max_value: 3.14)
  cmd.string("string", "string option", required: false, min_length: 8, max_length: 32)
end

BOT.application_command(:test) do |event|
  integer = event.options["integer"]
  number = event.options["number"]
  string = event.options["string"]

  event.respond(ephemeral: true) do |msg|
    msg.add_embed do |embed|
      embed.description = <<~MSG
        integer: #{integer}
        number: #{number}
        string: #{string}
      MSG
    end
  end
end

Copy link
Contributor

@Droid00000 Droid00000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@swarley swarley merged commit 080c159 into shardlab:main Oct 13, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants