0
votes

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

const fetch = require("node-fetch");

const querystring = require('querystring');

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)
        })
}
1
Because champS.data.champ is undefined. Please check the response from Curl - vadimk7
It's because I'm trying to take the proprieties of the champion using it name, in this case, the args[0] - Igor Duca

1 Answers