help.rb 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. HELP_BLUE = "#4976ca"
  2. def command_list_embed(commands, restriction = nil, title = nil)
  3. fields = []
  4. desc = "To learn more about any of the listed commands," +
  5. " use `pkmn-help [command]`"
  6. commands.each do |cmd|
  7. fields.push({name: "pkmn-#{cmd.name}", value: cmd.description})
  8. end
  9. desc = "#{restriction}\n#{desc}" if restriction
  10. Embed.new(
  11. title: title || "Commands",
  12. description: desc,
  13. color: HELP_BLUE,
  14. fields: fields
  15. )
  16. end
  17. def command_embed(command, restriction = nil)
  18. fields = usage_embed(command)
  19. title = "Usage"
  20. title += ": #{restriction}" if restriction
  21. embed = Embed.new(
  22. title: title,
  23. color: HELP_BLUE,
  24. footer: {
  25. text: "Questions? Ask a Guildmaster!"
  26. },
  27. fields: fields
  28. )
  29. embed.description = command.description if command.description
  30. embed
  31. end
  32. def usage_embed(command)
  33. fields = []
  34. command.options.map do |option, desc|
  35. fields.push({name: desc, value: "```pkmn-#{command.name} #{option}```"})
  36. end
  37. fields
  38. end