我找不到错误discord.js giphy / hug命令

时间:2020-08-15 14:04:28

标签: javascript discord.js giphy

const GphApiClient = require("giphy-js-sdk-core");
var giphy = GphApiClient ;
exports.run =  (bot, message, args, client) => {

giphy.search("gifs", { q: "fail" })
    .then(response => {
      var totalResponses = response.data.length;
      var responseIndex = Math.floor((Math.random() * 10) + 1) % totalResponses;
      var responseFinal = response.data[responseIndex]


 const embed = new Discord.RichEmbed() // Here is my problem it says 'Discord' is not defined
  .setAuthor('x')
  .setColor('RANDOM')
  .setTimestamp()
  .setDescription('')
  .setImage(responseFinal.images.fixed_height.url)        
  message.channel.send(embed)
}
)
}


exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: 0
};

exports.help = {
name: 'hug',
description: 'Free Hug!',
usage: 'hug'
};

我需要帮助:c我刚刚开始编码。我不知道那是什么错误

未定义“不一致”

如果发现错误,请让我不和谐。 万河达?#2722

1 个答案:

答案 0 :(得分:0)

您需要require discord.js:

const Discord = require("discord.js");
// rest of code...

我不知道怎么了

错误为'Discord' is not defined,这意味着Node.js在Discord中看到了Discord.RichEmbed并试图获取其值,但是没有变量Discord

请参见ReferenceError: "x" is not defined on MDN