reject.rb 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. MSG = "Please resubmit when you've addressed the issues!\n"
  2. FTR = "If you have any questions, feel free to ask a Guildmaster"
  3. def reject_app_embed(app, opts = nil)
  4. instr_check =
  5. "#{Emoji::CHECK} : Indicates you are ready to send the corresponding " +
  6. "messages to the user"
  7. instr_cross =
  8. "#{Emoji::CROSS} : Indicates you want to dismiss this message and " +
  9. "not send a message to the user"
  10. instr_crayon =
  11. "#{Emoji::CRAYON} : Indicates you want to edit the users form for " +
  12. "them, and resubmit on their behalf"
  13. fields = []
  14. #app.fields.each do |f|
  15. #fields.push({ name: f.name, value: f.value, inline: true })
  16. #end
  17. if opts
  18. fields.push({ name: "\u200b", value: "\u200b" })
  19. msgs =
  20. case opts
  21. when :character
  22. instructions = "#{instr_check}\n#{instr_cross}\n#{instr_crayon}"
  23. CharApp::REJECT_MESSAGES
  24. when :image
  25. instructions = "#{instr_check}\n#{instr_cross}"
  26. ImgApp::REJECT_MESSAGES
  27. else
  28. instructions = "#{instr_crayon}\n#{instr_cross}"
  29. end
  30. msgs.map do |emoji, message|
  31. fields.push({
  32. name: emoji,
  33. value: "#{message}\n#{CharApp::INLINE_SPACE}",
  34. inline: true
  35. })
  36. end
  37. fields.push({
  38. name: "Submitting",
  39. value: instructions
  40. })
  41. end
  42. embed = Embed.new(
  43. title: app.title,
  44. description: app.description,
  45. author: {
  46. name: app.author.name.gsub('Application', 'Rejection'),
  47. icon_url: app.author.icon_url
  48. },
  49. color: ERROR,
  50. footer: {
  51. text: app.footer.text
  52. },
  53. fields: fields
  54. )
  55. embed.thumbnail = { url: app.image.url } if app.image
  56. embed.thumbnail = { url: app.thumbnail.url } if app.thumbnail
  57. embed
  58. end
  59. def user_char_app(event)
  60. reactions = event.message.reactions
  61. app = event.message.embeds.first
  62. description = ""
  63. Emoji::CHAR_APP.each do |reaction|
  64. if reactions[reaction].count > 1
  65. m = CharApp::REJECT_MESSAGES[reaction].gsub("\n", " ")
  66. description += "\n#{m}"
  67. end
  68. end
  69. embed = Embed.new(
  70. title: "**Your application has been rejected!!**",
  71. color: ERROR,
  72. footer: {
  73. text: FTR
  74. },
  75. fields: [
  76. {
  77. name: "Listed reasons for rejection:",
  78. value: description
  79. },
  80. {
  81. name: MSG,
  82. value: "[Edit Your Application](#{Url::CHARACTER}#{app.footer.text})"
  83. }
  84. ]
  85. )
  86. embed
  87. end
  88. def user_img_app(event)
  89. reactions = event.message.reactions
  90. app = event.message.embeds.first
  91. description = ""
  92. Emoji::IMG_APP.each do |reaction|
  93. if reactions[reaction].count > 1
  94. m = ImgApp::REJECT_MESSAGES[reaction].gsub("\n", " ")
  95. description += "\n#{m}"
  96. end
  97. end
  98. description += "\n\n#{MSG}"
  99. embed = Embed.new(
  100. title: "**Your application has been rejected!!**",
  101. color: ERROR,
  102. footer: {
  103. text: FTR
  104. },
  105. fields: [
  106. {
  107. name: "Listed reasons for rejection:",
  108. value: description
  109. }
  110. ]
  111. )
  112. embed.thumbnail = { url: app.thumbnail.url } if app.thumbnail
  113. embed
  114. end
  115. def self_edit_embed(app, form)
  116. Embed.new(
  117. title: "Don't forget to resubmit!",
  118. color: ERROR,
  119. description: "[Edit the Application](#{form}#{app.footer.text})"
  120. )
  121. end
  122. def char_reactive(form, edit_url)
  123. Embed.new(
  124. title: "Your reactivation request has been declined!",
  125. color: ERROR,
  126. description: "[Edit the Application](#{form}#{edit_url})"
  127. )
  128. end