help.rb 888 B

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