global.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. UNKNOWN_USER_IMG = "https://i.imgur.com/oRJwgRa.png"
  2. ADOPT_IMG = "https://i.imgur.com/2u0fNd2.png"
  3. SUCCESS_GREEN = "#6bc037"
  4. ERROR_RED = "#c42d2d"
  5. def author_footer(embed, author, info=[])
  6. # Select the proper text and image for the author
  7. # .unshift places the argument at the beginning of an array
  8. img = case author
  9. when /Public/i
  10. info.unshift("Adopt Me!")
  11. ADOPT_IMG
  12. when nil
  13. info.unshift("Unknown User")
  14. UNKNOWN_USER_IMG
  15. else
  16. info.unshift("#{author.name}##{author.tag}")
  17. author.avatar_url
  18. end
  19. # Update the footer with the appropriate information
  20. embed.footer = {
  21. text: info.join(" | "),
  22. icon_url: img
  23. }
  24. embed
  25. end
  26. def message_embed(title, desc, img = nil)
  27. embed = Embed.new(
  28. title: title,
  29. description: desc,
  30. color: SUCCESS_GREEN,
  31. )
  32. embed.thumbnail = { url: img } if img
  33. embed
  34. end
  35. def success_embed(message)
  36. Embed.new(
  37. title: "Hooray!",
  38. description: message,
  39. color: SUCCESS_GREEN,
  40. footer: {
  41. text: "High Five!"
  42. }
  43. )
  44. end
  45. def error_embed(title, message = nil)
  46. embed = Embed.new(
  47. title: title,
  48. color: ERROR_RED,
  49. footer: {
  50. text: "For more help, feel free to ask a Moderator or Guildmaster"
  51. }
  52. )
  53. embed.description = message if message
  54. embed
  55. end
  56. def generic_error(message)
  57. Embed.new(
  58. title: "Error",
  59. description: message,
  60. color: ERROR_RED
  61. )
  62. end