Weather Command Added

This commit is contained in:
dragonfire535
2017-03-04 09:05:20 -05:00
parent dbb63369a7
commit 70ab53e0ce
3 changed files with 63 additions and 1 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class InfoCommand extends commando.Command {
.addField('Lib',
"[discord.js](https://discord.js.org/#/) (master)", true)
.addField('Packages',
"[Commando](https://github.com/Gawdl3y/discord.js-commando) (0.9.0), [cleverbot-node](https://github.com/fojas/cleverbot-node) (0.3.5), [pirate-speak](https://github.com/mikewesthad/pirate-speak) (1.0.1), [JIMP](https://github.com/oliver-moran/jimp) (0.2.27), [google-translate-api](https://github.com/matheuss/google-translate-api) (2.2.2), [urban](https://github.com/mvrilo/urban) (0.3.1), [zalgoize](https://github.com/clux/zalgolize) (1.2.4), [hepburn](https://github.com/lovell/hepburn) (1.0.0), [wikifakt](https://github.com/coffee-cup/wikifakt) (1.0.3), [osu](https://github.com/IOExceptionOsu/node-osu) (1.0.1)")
"[Commando](https://github.com/Gawdl3y/discord.js-commando) (0.9.0), [cleverbot-node](https://github.com/fojas/cleverbot-node) (0.3.5), [pirate-speak](https://github.com/mikewesthad/pirate-speak) (1.0.1), [JIMP](https://github.com/oliver-moran/jimp) (0.2.27), [google-translate-api](https://github.com/matheuss/google-translate-api) (2.2.2), [urban](https://github.com/mvrilo/urban) (0.3.1), [zalgoize](https://github.com/clux/zalgolize) (1.2.4), [hepburn](https://github.com/lovell/hepburn) (1.0.0), [wikifakt](https://github.com/coffee-cup/wikifakt) (1.0.3), [osu](https://github.com/IOExceptionOsu/node-osu) (1.0.1), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather) (2.2.2)")
.addField('Other Credit',
"[Cleverbot API](https://www.cleverbot.com/api/)")
.addField('My Server',
+61
View File
@@ -0,0 +1,61 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const weather = require('yahoo-weather');
class WeatherCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'weather',
group: 'search',
memberName: 'weather',
description: 'Searches weather for a specified location. (;weather San Francisco)',
examples: [';weather San Francisco']
});
}
async run(message, args) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
}
console.log("[Command] " + message.content);
let locationtosearch = message.content.split(" ").slice(1).join(" ");
weather(locationtosearch, 'f').then(info => {
const embed = new Discord.RichEmbed()
.setColor(0x0000FF)
.setAuthor(info.title, 'http://static.dnaindia.com/sites/default/files/2015/08/21/367776-yahoo2.jpg')
.setURL(info.link)
.setTimestamp()
.addField('**City:**',
info.location.city, true)
.addField('**Country**',
info.location.country, true)
.addField('**Region:**',
info.location.region, true)
.addField('**Condition:**',
info.item.condition.text, true)
.addField('**Temperature:**',
info.item.condition.temp + "°", true)
.addField('**Humidity:**',
info.atmosphere.humidity, true)
.addField('**Pressure:**',
info.atmosphere.pressure, true)
.addField('**Rising:**',
info.atmosphere.rising, true)
.addField('**Visibility:**',
info.atmosphere.visibility, true)
.addField('**Wind Chill:**',
info.wind.chill, true)
.addField('**Wind Direction:**',
info.wind.direction, true)
.addField('**Wind Speed:**',
info.wind.speed, true);
message.channel.sendEmbed(embed).catch(console.error);
}).catch(err => {
message.reply(":x: Error! Make sure you typed the location correctly!");
});
}
}
module.exports = WeatherCommand;
+1
View File
@@ -22,6 +22,7 @@
"pirate-speak": "^1.0.1",
"urban": "^0.3.1",
"wikifakt": "^1.0.3",
"yahoo-weather": "^2.2.2",
"zalgolize": "^1.2.4"
}
}