2017-06-10 51 views
1

我正在使用Discordrb Api编码Discord Bot,而且我无法找到一种方法来在我的计算机上共享图像以进行不一致的聊天,这就是为什么我在这里问你,我希望你能找到回答。如何与Discordrb Api共享图像?

这里是我的实际代码:

bot.command :food do |event| 

    agent = Mechanize.new 
    link = 'https://source.unsplash.com/random/featured/?Food' 
    agent.get(link).save "images/pic.jpg" 

end 

回答

0

好了,所以我已经找到一种方法来做到这一点

bot.command :food do |event| 

    agent = Mechanize.new 
    link = 'https://source.unsplash.com/random/featured/?Food,Plate' 
    agent.get(link).save "pic.png" 
    event.send_file(File.open('pic.png', 'r'), caption: "Voiçi votre repas # 
    {event.user.name} .") 
    sleep(5) 
    event File.delete("pic.png") 

end 

我希望这可以帮助一些人。