From afcb1a3da3f9c56d52532f5de64d08aac5c79e3e Mon Sep 17 00:00:00 2001 From: chris062689 Date: Sat, 31 Dec 2016 17:10:20 -0500 Subject: [PATCH] Check if Github PR exists before posting it. --- triggers/github.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/triggers/github.js b/triggers/github.js index 0f1c699..7548800 100644 --- a/triggers/github.js +++ b/triggers/github.js @@ -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. + } + }); } }