简体   繁体   English

需要帮助修复我的天气命令的错误

[英]Need help fixing a error with my weather command

so my i made a weather command but when a user puts to location it sends a error here is my command and my error is telling me if can't find length when a user doesn't put a location所以我做了一个天气命令,但是当用户放置位置时,它会发送一个错误,这是我的命令,我的错误告诉我当用户没有放置位置时是否找不到长度

else if (command === 'weather') {
         weather.find({search: args.join(" "), degreeType: "C"}, function(err, result) {
        if(err) message.channel.send(err)

        if(result.length === 0) {
            message.channel.send("**please enter a valid location**")
            return;
        }

        var current = result[0].current 
        var location = result[0].location 

        let embed = new Discord.MessageEmbed()
           .setDescription(`**${current.skytext}**`) 
           .setAuthor(`Weather for ${current.observationpoint}`) 
           .setThumbnail(current.imageUrl) 
           .setColor("RANDOM") 
           .addField("Timezone", `UTC${location.timezone}`, true) 
           .addField("Degree Type", location.degreetype, true) 
           .addField("Temperature", `${current.temperature}`, true)
           .addField("Feels like", `${current.feelslike} Degrees`, true)
           .addField("Winds", current.winddisplay, true)
           .addField("Humidity", ` ${current.humidity}%`, true)
           .addField("Day", `${current.day}`, true)
           .addField("Date", `${current.date}`, true)
           
           message.channel.send(embed)```

Return if there's an error如果有错误返回

if(err) {
  message.channel.send(err)
  return
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM