我的代码的 let 部分产生了一个错误我想出了为什么机器人不会通过将 client.login 移动到底部来启动新错误包括它只是垃圾邮件“无效的邮政编码。请遵循以下格式:_weather <### ##>" 即使你输入了邮政编码
client.on("message", (message) => {
if (message.content.includes("_weather") && message.author.bot === false)
let zipCode = message.content.split(" ")[1];
if (zipCode === undefined || zipCode.length != 5 || parseInt(zipCode) === NaN) {
message.channel.send("`Invalid Zip Code. Please follow the format: _weather <#####>`")
.catch(console.error);
return;
} else {
fetch(`https://openweathermap.org/data/2.5/weather?zip=${zipCode},us&appid=439d4b804bc8187953eb36d2a8c26a02`)
.then(response => {
return response.json();
})
.then(parsedWeather => {
if (parsedWeather.cod === '404') {
message.channel.send("`This zip code does not exist or there is no information avaliable.`");
} else { …Run Code Online (Sandbox Code Playgroud) //libraries
#include <iostream>
//standard namepace
using namespace std;
int Car() {
int a;
int b;
cout << "Fuel Tank" << endl;
cin >> a;
cout << "MPG" << endl;
cin >> b;
return a, b;
}
int main() {
int a;
int b;
a,b = Car();
cout << "Print Values " << (a,b); // <--- Line 25
return 0;
}
Run Code Online (Sandbox Code Playgroud)
假设您将 10 和 15 作为第一个和第二个输入。为什么 15 是cout第 25 行语句中唯一要打印的变量。