Map Command

This commit is contained in:
Daniel Odendahl Jr
2017-04-15 15:29:04 +00:00
parent 1cb782c44c
commit 90d3e66e89
7 changed files with 62 additions and 6 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ You can join the home server with [this link](https://discord.gg/fqQF8mc).
[discord.js](https://discord.js.org/#/), [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/)
## 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/)
## Self-Hosting
You can Self-Host the bot easily, provided you have API keys and a Discord Bot Token. [Node.js](https://nodejs.org/en/) is also required, with at least version 7.8.0 recommended.
+55
View File
@@ -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!');
}
}
};
+1 -1
View File
@@ -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()
+2 -2
View File
@@ -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);
}
};
+1
View File
@@ -44,6 +44,7 @@
<li><a href="https://developer.yahoo.com/weather/">Yahoo Weather</a></li>
<li><a href="https://translate.yandex.com/developers">Yandex.Translate</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps/documentation/static-maps/">Google Static Maps</a></li>
</ul>
<h2>Information</h2>
<ul>
+1 -1
View File
@@ -90,12 +90,12 @@
<li><a href="https://developer.yahoo.com/weather/">Yahoo Weather</a></li>
<li><a href="https://translate.yandex.com/developers">Yandex.Translate</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps/documentation/static-maps/">Google Static Maps</a></li>
</ul>
</ul>
<h2>Information</h2>
<ul>
<li><a href="https://discord.gg/fqQF8mc">Home Server</a></li>
<li>Command Count: 110</li>
<li>Server Host: <a href="https://www.heroku.com/">Heroku</a></li>
</ul>
</div>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "24.4.0",
"version": "24.5.0",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {