forked from Supositware/Haha-Yes
Added a basic weather command
This commit is contained in:
parent
dd9738471c
commit
a2519de93b
2 changed files with 38 additions and 1 deletions
36
commands/fun/weather.js
Normal file
36
commands/fun/weather.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
module.exports = class WeatherCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'weather',
|
||||||
|
group: 'fun',
|
||||||
|
memberName: 'weather',
|
||||||
|
description: `Choose the city you want to know the weather`,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'city',
|
||||||
|
prompt: 'city',
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, { city }) {
|
||||||
|
const { body } = await snekfetch.get('https://api.openweathermap.org/data/2.5/weather?q='+ city +'&units=metric&APPID=688e6d7bcdfdc4b71d921a3de461f76b');
|
||||||
|
if (!body.main.temp) {
|
||||||
|
return message.say(`No results found for **${city}**`);
|
||||||
|
}
|
||||||
|
const test = new Discord.RichEmbed()
|
||||||
|
.setColor("#ff9900")
|
||||||
|
.setTitle(body.name + ' current weather')
|
||||||
|
.setDescription(body.main.temp + '°c')
|
||||||
|
.addField('Temp min', body.main.temp_min + '°c')
|
||||||
|
.addField('Temp max', body.main.temp_max + '°c')
|
||||||
|
|
||||||
|
|
||||||
|
message.say(test);
|
||||||
|
}
|
||||||
|
};
|
|
@ -19,6 +19,7 @@
|
||||||
"homepage": "https://gitlab.com/loicbersier/discordbot#readme",
|
"homepage": "https://gitlab.com/loicbersier/discordbot#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"discord.js-commando": "^0.10.0"
|
"discord.js-commando": "^0.10.0",
|
||||||
|
"snekfetch": "^4.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue