[英]How to fix an error with the weather command
const Discord = require('discord.js');
const weather = require('weather-js');
module.exports = {
name: 'weather',
description: 'weather',
execute(message, args){
const { prefix, token } = require ('../config.json');
if(!args.length) {
return message.channel.send("Please give the weather location")
}
weather.find({search: args.join(" "), degreeType: 'C'}, function(err, result) {
try {
let embed = new discord.MessageEmbed()
.setTitle(`weather - ${result[0].location.name}`)
.setColor("#fffff1")
.setDescription("Temperature units can may be differ some time")
.addField("Temperature", `${result[0].current.temperature} Celcius`, true)
.addField("Sky Text", result[0].current.skytext, true)
.addField("Humidity", result[0].current.humidity, true)
.addField("Wind Speed", result[0].current.windspeed, true)//What about image
.addField("Observation Time", result[0].current.observationtime, true)
.addField("Wind Display", result[0].current.winddisplay, true)
.setThumbnail(result[0].current.imageUrl);
message.channel.send(embed)
} catch(err) {
return message.channel.send("Unable To Get the data of Given location")
}
});
}
}
When I use the command !weather , works normally showing Provides the location of the climate
当我使用命令!weather 时,正常工作显示
Provides the location of the climate
But if I place the city, for example !weather Los Angeles , it always gives me the error Unable To Get the data of Given location
, any city I place always appears like this.但是如果我放置城市,例如!weather Los Angeles ,它总是给我错误
Unable To Get the data of Given location
,我放置的任何城市总是这样出现。
Say... did you realize your discord identifier is wrong?说...你有没有意识到你的不和谐标识符是错误的?
const Discord = require('discord.js')
then然后
...
let embed = new discord.MessageEmbed()
...
Try Changing it to:尝试将其更改为:
...
let embed = new Discord.MessageEmbed()
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.