【发布时间】:2020-09-25 02:53:57
【问题描述】:
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) => { 常量冠军 = 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)
})
}
【问题讨论】:
-
因为
champS.data.champ未定义。请查看Curl的回复 -
这是因为我试图使用它的名字来获取冠军的礼仪,在这种情况下,args[0]
标签: javascript api discord.js