From 8d65887797948bbbcc9a9b513f10dfe5cd20c697 Mon Sep 17 00:00:00 2001 From: takumi091111 Date: Thu, 12 Oct 2017 22:47:13 +0900 Subject: [PATCH] Changed to return embed --- lib/commands/shorten.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/commands/shorten.rb b/lib/commands/shorten.rb index d238614..4e39785 100644 --- a/lib/commands/shorten.rb +++ b/lib/commands/shorten.rb @@ -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