!weather [city name] shows the weather of that city. To use this, you need to go to https://www.weatherapi.com/signup.aspx and make an account, then go to https://www.weatherapi.com/my/ and copy your api key. After copying the api key you need to insert it at line 9 where it saying YourAPIKeyHere and then you are ready to go. Dm Nintendo_bot#7518 for help.
//!weather [city name] shows the weather of that city.
//To use this, you need to go to https://www.weatherapi.com/signup.aspx and make an account.
//then you need to go to https://www.weatherapi.com/my/ and copy your api key.
//After copying the api key you need to insert it at line 9 where it saying YourAPIKeyHere and then you are ready to go.
//Dm Nintendo_bot#7518 for help.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
if (context.params.event.content.startsWith('!weather')) {
const args = context.params.event.content.split(' ').slice(1);
const apiKey = `YourAPIkeyGoesHere`; //Add API key here
if (!args.length)
return lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `No arguments provided. It should be used as !weather [city name]`,
});
let info = await lib.http.request['@1.1.5'].get({
url: `http://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${args}&aqi=no`,//insert API key in this line where it says 'YourAPIKeyGoesHere'
});
let message = await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embed: {
type: 'rich',
title: ``,
description: [
`πΊοΈ **Location:** ${info.data.location.name}, ${info.data.location.region}, ${info.data.location.country}`,
`β **Local Time:** ${info.data.location.localtime}`,
`β³ **Last Updated:** ${info.data.current.last_updated}`,
`π¦οΈ **Condition:** ${info.data.current.condition.text}`,
`π‘οΈ **Temperture:** ${info.data.current.temp_c}Β°C, ${info.data.current.temp_f}Β°F`,
`π₯΅ **Feels Like:** ${info.data.current.feelslike_c}Β°C, ${info.data.current.feelslike_f}Β°F`,
`π **Wind:** ${info.data.current.wind_mph} mph, ${info.data.current.wind_kph} kph`,
`π§ **Wind Direction:** ${info.data.current.wind_dir}`,
`π¨ **Pressure:** ${info.data.current.pressure_mb} mb, ${info.data.current.pressure_in} in`,
`π§ **Precipitation:** ${info.data.current.precip_mm} mm, ${info.data.current.precip_in} in`,
`π§ **Humidity:** ${info.data.current.humidity}`,
`βοΈ **UV:** ${info.data.current.uv}`,
].join('\n'),
color: 0x009eff,
thumbnail: {
url: `https:${info.data.current.condition.icon}`,
height: 64,
width: 64,
},
},
});
}