mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Weather Command Added
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user