【发布时间】:2021-04-07 10:22:08
【问题描述】:
我正在尝试在我的 discord.js 机器人中放置一个受诅咒的图像命令,但它不断出现此错误
got('https://www.reddit.com/r/madlads/random/.json').then(response => {
^
ReferenceError: got is not defined
这里是代码
if(command === "cursed") {
got('https://www.reddit.com/r/cursedimages/random/.json').then(response => {
let content = JSON.parse(response.body);
var image = content[0].data.children[0].data.url;
let permalink = content[0].data.children[0].data.permalink;
let memeUrl = `https://reddit.com${permalink}`;
let memeImage = content[0].data.children[0].data.url;
let memeTitle = content[0].data.children[0].data.title;
let memeUpvotes = content[0].data.children[0].data.ups;
let memeNumComments = content[0].data.children[0].data.num_comments;
const cursedembed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setTitle(content[0].data.children[0].data.title)
.setURL(`${memeUrl}`)
.setImage(image)
.setFooter(`???? ${memeUpvotes} ???? ${memeNumComments}`)
.setTimestamp()
message.channel.send(cursedembed);
});
}
【问题讨论】:
-
你确定你输入的是
get而不是got? -
这两种方法我都试过了,都出现了这个错误
-
如果您尝试使用
fetch而不是get会怎样? -
它仍然显示未定义
-
你有
node-fetch作为你的包之一吗?
标签: discord.js