help.rb 911 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. HELP_BLUE = "#4976ca"
  2. def all_commands_embed(commands)
  3. fields = []
  4. desc = "To learn more about any of the listed commands," +
  5. " use `pkmn-help [command]`"
  6. commands.each do |command|
  7. fields.push({name: "pkmn-#{command.name}", value: command.description})
  8. end
  9. Embed.new(
  10. title: "Commands",
  11. description: desc,
  12. color: HELP_BLUE,
  13. fields: fields
  14. )
  15. end
  16. def command_embed(command)
  17. fields = command_usage(command)
  18. Embed.new(
  19. title: "pkmn-#{command.name}",
  20. description: command.description,
  21. color: HELP_BLUE,
  22. fields: fields
  23. )
  24. end
  25. def command_usage(command)
  26. fields = []
  27. unless command.options.empty?
  28. usage = "```bash\n"
  29. command.options.map do |option, description|
  30. usage += "##{description}\npkmn-#{command.name} #{option}\n\n"
  31. end
  32. usage += "```"
  33. end
  34. fields.push({name: "Usage", value: usage}) if command.options
  35. fields
  36. end