为什么我有此错误:(节点:16040)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“ title”

时间:2020-06-05 19:48:35

标签: javascript api discord.js

const Discord = require('discord.js') const riotapi = require('../ botconfig.json')

const fetch = require(“ node-fetch”);

const querystring = require('querystring');

module.exports.run =异步(客户端,消息,参数)=> { 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)
        })
}

1 个答案:

答案 0 :(得分:0)