diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index 32941936..60882013 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -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', diff --git a/commands/search/weather.js b/commands/search/weather.js new file mode 100644 index 00000000..7e56e9f1 --- /dev/null +++ b/commands/search/weather.js @@ -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; \ No newline at end of file diff --git a/package.json b/package.json index 1c0abcf5..f2b32137 100644 --- a/package.json +++ b/package.json @@ -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" } }