我目前正在尝试制造一个不和谐的机器人,当我输入-gif参数时,如果显示一个丰富的嵌入,如图像中所示,搜索到的gif。由于某些原因,如果我发送了男高音api链接,它本身工作良好,但如果我显示它与嵌入图像,它显示任何东西,甚至使用相同的链接。我检查了嵌入显示图像的链接,它不是以.gif结尾的直接链接,但是如果我将.gif添加到该链接的末尾,它就是浏览器中显示的直接链接,但不一致并不像对待它一样。代码:
const Tenor = require("tenorjs").client({
"Key": "Ihaveakeyjustnotshowingit", // https://tenor.com/developer/keyregistration
"Filter": "off", // "off", "low", "medium", "high", not case sensitive
"Locale": "en_US", // Your locale here, case-sensitivity depends on input
"MediaFilter": "minimal", // either minimal or basic, not case sensitive
"DateFormat": "MM/D/YYYY - H:mm:ss A" // Change this accordingly
});
const fs = require('fs');
const discord = require('discord.js');
module.exports = {
name: 'gif',
aliases: ['tenor', 'gifsearch', 'gf'],
category: 'Funny',
utilisation: '{prefix}gif',
execute(client, message, args) {
const msgArgs = message.content.slice(this.name.length + 1)
Tenor.Search.Query(msgArgs, "1").then(Results => {
Results.forEach(Post => {
message.channel.send({
embed: {
title: 'Women',
color: 'c20d00',
image: {
url: (Post.itemurl),
},
},
})
message.channel.send(Post.itemurl)
});
}).catch(console.error);
},
};如果我将.gif添加到embed链接中,只会显示嵌入中的poop错误消息。我应该做些什么,这样它才能正确地显示在一个嵌入,而不是仅仅是作为一个信息本身发送,1 (不要介意奇怪的gif男高音选择发送)。我还发现了其他具有类似问题的论坛,它们通过在.media属性之前添加.url来解决这个问题,但它也给我提供了一个TypeError: Cannot read property 'media' of undefined错误,这就导致了在嵌入2中不显示任何内容的问题。url: (Post.media[0].itemurl),谢谢
发布于 2021-10-06 03:37:16
根据tenorJS文档,您可以使用Post.url获得post的url,所以尝试用URL替换itemurl,它应该直接输出图像url。
https://stackoverflow.com/questions/69457056
复制相似问题