[英]Why i"m having this error: (node:16040) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'title' of undefined
const Discord = require('discord.js') const riotapi = require('../botconfig.json') const Discord = require('discord.js') const riotapi = require('../botconfig.json')
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const querystring = require('querystring');常量查询字符串 = 要求('查询字符串');
module.exports.run = async (client, message, args) => { const champ = args[0] module.exports.run = async (client, message, args) => { const champ = args[0]
const Curl = `http://ddragon.leagueoflegends.com/cdn/10.11.1/data/pt_BR/champion/${champ}.json`
const imgUrl = `http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/${champ}.png`
console.log(Curl)
message.channel.send("Procurando pelo campeão: " + champ).then(message => message.delete({timeout: 1000}))
fetch(Curl)
.then(res => res.json())
.then(champS => {
let champEmbed = new Discord.MessageEmbed()
.setTitle(`${champ}`)
.setDescription(`${champS.data.champ.title}`)
.addField("Classe", `${champS.data.champ.tags}`)
.addField("Dicas para aprimorar as fights!", `${champS.data.champ.enemytips}`)
.addField("Dicas para ajudar o time!", `${champS.data.champ.allytips}`)
.addField("Passiva", `${champS.data.champ.passive.description}`)
.setThumbnail(imgUrl)
.setColor("RED")
.setFooter("Grandmaster, by: IgorDuca")
message.channel.send(champEmbed)
})
}
Try embed.setTitle
or visit this website for define it试试
embed.setTitle
或访问这个网站来定义它
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.