我正在使用 Discordrb Api 编写一个 Discord Bot,但我找不到在我的计算机上将图像共享到 discord 的方法。
bot.command :food do |event|
agent = Mechanize.new
link = 'https://source.unsplash.com/random/featured/?Food'
agent.get(link).save "images/pic.jpg"
end
最佳答案
好的,我找到了一个方法来做到这一点
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
我希望这可以帮助一些人。
关于ruby - 如何使用 Discordrb Api 共享图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44478224/