team.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. TEAM_BLUE = '#3498db'.freeze
  2. def team_embed(team)
  3. fields = []
  4. active = []
  5. members = CharTeam.where(team_id: team.id)
  6. members.each do |member|
  7. active.push(Character.find(member.char_id).name) if member.active
  8. end
  9. unless active.empty?
  10. fields.push({
  11. name: 'Active Members',
  12. value: active.join(', ')
  13. })
  14. end
  15. embed = Embed.new(
  16. title: team.name,
  17. color: TEAM_BLUE,
  18. fields: fields
  19. )
  20. embed.description = team.description if team.description
  21. embed
  22. end
  23. def teams_embed
  24. fields = []
  25. active = []
  26. inactive = []
  27. teams = Team.all
  28. teams.each do |team|
  29. if team.active
  30. active.push(team.name)
  31. else
  32. inactive.push(team.name)
  33. end
  34. end
  35. unless active.empty?
  36. fields.push({
  37. name: 'Active Teams',
  38. value: active.join(', ')
  39. })
  40. end
  41. unless inactive.empty?
  42. fields.push({
  43. name: 'Inactive Teams',
  44. value: inactive.join(', ')
  45. })
  46. end
  47. Embed.new(
  48. title: 'Rescue Teams',
  49. description: 'Use `pkmn-team team_name` to learn more',
  50. color: TEAM_BLUE,
  51. fields: fields
  52. )
  53. end
  54. def team_alert(char, teams)
  55. Embed.new(
  56. author: { name: 'Team Alert' },
  57. description: "By archiving #{char.name}, you will be removed from " +
  58. "#{teams.join(' & ')}\n**Are you sure?**",
  59. footer: { text: char.id },
  60. color: TEAM_BLUE
  61. )
  62. end