Space commands!

This commit is contained in:
plane000
2018-05-22 21:32:04 +01:00
parent 3c2d6ea65f
commit f928baf779
4 changed files with 32 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ const Logger = require('./logger');
const Config = require('./config');
const Commands = require('./commands/commands')
const MultiServerCommands = require('./commands/multiservercommands')
const SpaceCommands = require('./commands/spacecommands')
const AdminCommands = require('./commands/admincommands')
const CommandManager = require('./main');
@@ -48,6 +49,9 @@ module.exports.loadCommands = function() {
addCommand('Poll', 'poll', undefined, 'poll start [option1/option2...] or poll stop', 'Starts/stops an automated poll with the options given as a third argument to \'poll start\' and are seperated with a \'/\' with no spaces, stopping a poll will produce the results', false, MultiServerCommands.poll);
addCommand('Vote', 'vote', undefined, 'vote [option]', 'Places your vote on the option you chose, based on the running poll in the server the \'poll start\' command was issued in', false, MultiServerCommands.vote);
//space commands
addCommand('Next Launch', 'nextlaunch', undefined, 'nextlaunch', 'Returns information on the next significant space flight in the space industry', false, SpaceCommands.nextlaunch);
//admin commands
addCommand('Shutdown', 'stop', undefined, 'stop', 'Shutsdown JefferyBot', true, AdminCommands.stop);
addCommand('Reload', 'reload', undefined, 'reload', 'Reloads the server config and the misc config', false, AdminCommands.reload);

View File

@@ -65,9 +65,9 @@ module.exports.dog = async function(message, msg, args, discordclient) {
var url = 'https://dog.ceo/api/breeds/image/random';
try {
var result = await Helper.requestPromise(url);
var output = JSON.parse(result).message;
var output = JSON.parse(result).messsage;
} catch (e) {
message.channel.send(`:no_entry_sign: \`Somthing went wrong\``);
message.channel.send(`:no_entry_sign: \`There was a problem with the API...\``);
return;
}
var em = new Discord.RichEmbed();
@@ -92,6 +92,7 @@ module.exports.undo = function (message, msg, args, discordclient) {
module.exports.hug = function(message, msg, args, discordclient) {
var em = new Discord.RichEmbed();
em.setColor('BLUE');
em.setImage('https://cdn.discordapp.com/attachments/345580737149403146/442232811605458957/cat-instantly-hugs-plush-toy.gif');
message.channel.send(em);
}
}

23
commands/spacecommands.js Normal file
View File

@@ -0,0 +1,23 @@
const Discord = require('discord.js');
const ping = require('ping');
const fs = require('fs');
const Config = require('../config.js');
const Helper = require('../helper.js');
/*message object, messaage full, message args, discord client*/
module.exports.nextlaunch = async function(message, msg, args, discordclient) {
var url = 'https://launchlibrary.net/1.4/launch/next/1';
try {
var result = await Helper.requestPromise(url);
var json = JSON.parse(result).launches;
var em = new Discord.RichEmbed();
em.setTitle(json.name);
message.channel.send(em);
} catch (e) {
console.log(e);
message.channel.send(`:no_entry_sign: \`There was a problem with the API...\``);
}
}

View File

@@ -9,7 +9,7 @@ const Config = require('./config');
const Commands = require('./commands/commands')
const CommandManager = require('./commandmanager');
module.exports.requestPromise = function(url) {
module.exports.requestPromise = async function(url) {
return new Promise((resolve, reject) => {
request(url, function(error, response, body) {
if (error) {