team.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. TEAM_BLUE = "#3498db"
  2. def team_embed(team)
  3. fields = []
  4. active = []
  5. members = CharTeam.where(team_id: team.id)
  6. members.each do |member|
  7. if member.active
  8. active.push(Character.find(member.char_id).name)
  9. end
  10. end
  11. fields.push({
  12. name: 'Active Members',
  13. value: active.join(", ")
  14. })unless active.empty?
  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. fields.push({
  36. name: 'Active Teams',
  37. value: active.join(", ")
  38. })unless active.empty?
  39. fields.push({
  40. name: 'Inactive Teams',
  41. value: inactive.join(", ")
  42. })unless inactive.empty?
  43. Embed.new(
  44. title: 'Rescue Teams',
  45. description: 'Use `pkmn-team team_name` to learn more',
  46. color: TEAM_BLUE,
  47. fields: fields
  48. )
  49. end
  50. def team_alert(char, teams)
  51. Embed.new(
  52. author: { name: 'Team Alert' },
  53. description: "By archiving #{char.name}, you will be removed from " +
  54. "#{teams.join(" & ")}\n**Are you sure?**",
  55. footer: { text: char.id },
  56. color: TEAM_BLUE
  57. )
  58. end