Changed to return embed

This commit is contained in:
takumi091111
2017-10-12 22:47:13 +09:00
parent 6fc7e222b1
commit 8d65887797

View File

@ -11,7 +11,20 @@ module Bot
body = {"longUrl" => url}.to_json
res = post_json(SHORTEN_URL + CONFIG[:google][:apikey], body)
json = JSON.parse(res.body)
event.respond json["id"]
event.channel.send_embed do |embed|
embed.color = CONFIG[:google][:color]
embed.author = Discordrb::Webhooks::EmbedAuthor.new(
name: 'URL Shortener',
icon_url: 'https://lh3.googleusercontent.com/kroer1kpwSe3j-lIfPnE7Q3MVaCoJVF8atjdh0VtGDWCz2ulLejVsDh2k6a6VUgpUFQ8qRMHMEX7bsr2jTrLXhZR_ETbqILDf-qfkk0=h128'
)
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
text: "Created by #{event.author.name}",
icon_url: "#{event.author.avatar_url}"
)
embed.add_field(name: 'Original', value: "#{url}")
embed.add_field(name: 'Shortened', value: "#{json["id"]}")
end
end
end
end