item.rb 725 B

1234567891011121314151617181920212223242526272829303132
  1. def item_embed(item, event)
  2. # Find the author, if they're a member, or in DMs use the event's author
  3. member = if item.user_id.match(/public/i)
  4. 'Public'
  5. else
  6. event.server.member(item.user_id)
  7. end
  8. fields = []
  9. embed = Embed.new(
  10. title: item.name,
  11. description: item.description
  12. )
  13. embed.thumbnail = { url: item.url } if item.url
  14. author_footer(
  15. embed,
  16. member,
  17. [item.category.join(', '), item.reusable ? 'Reusable' : 'Not Resuable']
  18. )
  19. fields.push({ name: 'Effect', value: item.effect }) if item.effect
  20. embed.fields = fields
  21. embed
  22. end
  23. def item_list
  24. Embed.new(
  25. title: 'Items',
  26. description: Item.all.map(&:name).join(', ')
  27. )
  28. end