Class: Rubot::BetterEmbed

Inherits:
Discordrb::Webhooks::Embed
  • Object
show all
Defined in:
lib/rubot/utils/better_embed.rb

Instance Method Summary collapse

Constructor Details

#initialize(template = nil) ⇒ BetterEmbed



6
7
8
9
# File 'lib/rubot/utils/better_embed.rb', line 6

def initialize(template = nil)
  super()
  templates(template.to_sym) if template
end

Instance Method Details

#author(author) ⇒ Discordrb::Webhooks::Embed

set the embed's author



33
34
35
36
# File 'lib/rubot/utils/better_embed.rb', line 33

def author(author)
  self.author = author
  self
end

#color(color) ⇒ Discordrb::Webhooks::Embed

set the embed's color



65
66
67
68
# File 'lib/rubot/utils/better_embed.rb', line 65

def color(color)
  self.color = color
  self
end

#description(description) ⇒ Discordrb::Webhooks::Embed

set the embed's description



41
42
43
44
# File 'lib/rubot/utils/better_embed.rb', line 41

def description(description)
  self.description = description
  self
end

set the embed's footer



73
74
75
76
# File 'lib/rubot/utils/better_embed.rb', line 73

def footer(footer)
  self.footer = footer
  self
end

#image(image) ⇒ Discordrb::Webhooks::Embed

set the embed's image



97
98
99
100
# File 'lib/rubot/utils/better_embed.rb', line 97

def image(image)
  self.image = image
  self
end

#templates(template) ⇒ Discordrb::Embed

Returns prebuilt Discordrb::Embed.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubot/utils/better_embed.rb', line 13

def templates(template)
  Hash[
    :default => proc do
      timestamp(Time.at(Time.now.to_i))
      color("ffbc95")
    end,
    :error => proc do
      timestamp(Time.at(Time.now.to_i))
      color("ffbc95")
    end,
    :success => proc do
      timestamp(Time.at(Time.now.to_i))
      color("ffbc95")
    end
  ][template.to_sym].call
end

#thumbnail(thumbnail) ⇒ Discordrb::Webhooks::Embed

set the embed's thumbnail



89
90
91
92
# File 'lib/rubot/utils/better_embed.rb', line 89

def thumbnail(thumbnail)
  self.thumbnail = thumbnail
  self
end

#timestamp(timestamp) ⇒ Discordrb::Webhooks::Embed

set the embed's timestamp



81
82
83
84
# File 'lib/rubot/utils/better_embed.rb', line 81

def timestamp(timestamp)
  self.timestamp = timestamp
  self
end

#title(title) ⇒ Discordrb::Webhooks::Embed

set the embed's title



49
50
51
52
# File 'lib/rubot/utils/better_embed.rb', line 49

def title(title)
  self.title = title
  self
end

#url(url) ⇒ Discordrb::Webhooks::Embed

set the embed's url



57
58
59
60
# File 'lib/rubot/utils/better_embed.rb', line 57

def url(url)
  self.url = url
  self
end