Check if Github PR exists before posting it.

This commit is contained in:
chris062689 2016-12-31 17:10:20 -05:00
parent 4ac59532ae
commit afcb1a3da3

View File

@ -1,3 +1,4 @@
var request = require('request');
var app = require('../app.js');
var logger = require('../logging.js');
@ -8,9 +9,15 @@ exports.trigger = function(message) {
}
exports.execute = function(message) {
var match = regex.exec(message.content);
let match = regex.exec(message.content);
if (match) {
var msg = `Github Pull Request: https://github.com/citra-emu/citra/pull/${match[0].substring(1).trim()}`;
message.channel.sendMessage(msg);
let url = `https://github.com/citra-emu/citra/pull/${match[0].substring(1).trim()}`
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
message.channel.sendMessage(`Github Pull Request: ${url}`);
} else {
// Github PR does not exist.
}
});
}
}