[英]Now showing URL image discord.js
This is the code:这是代码:
fetch(`https://api.tenor.com/v1/random?key=${tenorAPI}&q=anime+kiss&limit=1.`)
.then(res => res.json())
.then(json => message.channel.send() + message.say(json.results[0].url))
const embed = new MessageEmbed()
.setDescription(`**${user.username}** you've kissed by **${message.author.username}**! OwO`)
.setColor("RANDOM")
.setImage(`https://api.tenor.com/v1/random?key=${tenorAPI}&q=anime+kiss&limit=1.gif`)
message.channel.send(embed).then(message.react('🥰'));
return;
I want to know how can I do to see the GIF我想知道如何才能看到 GIF
Other command not embedded it shows未嵌入的其他命令显示
It works perfectly now, this is the code,it is similar to the previous user but there was an error现在完美运行,这是代码,与之前的用户类似,但出现错误
const embed = new MessageEmbed()
.setDescription(`**${user.username}** you've kissed by **${message.author.username}**! OwO`)
.setColor("RANDOM")
fetch(`https://api.tenor.com/v1/random?key=${tenorAPI}&q=anime+kiss&limit=1`)
.then(res => res.json())
.then(json => {
embed.setImage(json.results[0].media[0].gif.url);
message.channel.send(embed).then(message.react('🥰'));
})
I've also found this problem when I created a gif search function on my bot.当我在我的机器人上创建一个 gif 搜索功能时,我也发现了这个问题。
The way around this is to not use the url property, but rather the .media[0].gif.url
when using the setImage method on embeds.解决此问题的方法是在嵌入时使用 setImage 方法时不使用 url 属性,而是使用
.media[0].gif.url
。
Also, it's a good idea to not set your image to have your api key, lol另外,最好不要将图像设置为具有 api 密钥,哈哈
The following code should work:以下代码应该可以工作:
const embed = new MessageEmbed()
.setDescription(`**${user.username}** you've kissed by **${message.author.username}**! OwO`)
.setColor("RANDOM")
fetch(`https://api.tenor.com/v1/random?key=${tenorAPI}&q=anime+kiss&limit=1.`)
.then(res => res.json())
.then(json => {
embed.setImage(json.results[0].media[0].gif.url);
message.channel.send(embed).then(message.react('🥰'));
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.