mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 08:08:34 +02:00
Map Command
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class MapCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'map',
|
||||
aliases: [
|
||||
'location'
|
||||
],
|
||||
group: 'search',
|
||||
memberName: 'map',
|
||||
description: 'Gets a map image for the location you define with the zoom level you define (1-20). (;map 15 Cartersville, GA)',
|
||||
examples: [';map 15 Cartersville, GA'],
|
||||
args: [{
|
||||
key: 'zoom',
|
||||
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
|
||||
type: 'integer',
|
||||
validate: zoom => {
|
||||
if (zoom < 21 && zoom > 0) {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter a zoom value from 1-20';
|
||||
}
|
||||
}, {
|
||||
key: 'locationQ',
|
||||
prompt: 'What location you like to get a map image for?',
|
||||
type: 'string'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
|
||||
}
|
||||
const zoom = args.zoom;
|
||||
const locationQ = args.locationQ;
|
||||
try {
|
||||
const response = await request
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: locationQ,
|
||||
zoom: zoom,
|
||||
size: '500x500',
|
||||
key: process.env.GOOGLE_KEY
|
||||
});
|
||||
return message.channel.sendFile(response.body);
|
||||
}
|
||||
catch (err) {
|
||||
return message.say(':x: Error! Something went wrong! Make sure you entered the location correctly!');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -35,7 +35,7 @@ module.exports = class YouTubeCommand extends Command {
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: video,
|
||||
key: process.env.YOUTUBE_KEY
|
||||
key: process.env.GOOGLE_KEY
|
||||
});
|
||||
const data = response.body.items[0];
|
||||
const embed = new RichEmbed()
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = class InfoCommand extends Command {
|
||||
.addField('Shards',
|
||||
`${this.client.options.shardCount} (${this.client.shard.id})`, true)
|
||||
.addField('Commands',
|
||||
'110', true)
|
||||
'111', true)
|
||||
.addField('Owner',
|
||||
'dragonfire535#8081', true)
|
||||
.addField('Source Code',
|
||||
@@ -49,7 +49,7 @@ module.exports = class InfoCommand extends Command {
|
||||
.addField('Modules',
|
||||
'[commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)')
|
||||
.addField('APIs',
|
||||
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Yandex.Translate](https://translate.yandex.com/developers), [Wikipedia](https://en.wikipedia.org/w/api.php)');
|
||||
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Yandex.Translate](https://translate.yandex.com/developers), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/)');
|
||||
return message.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user