Created
June 6, 2020 20:14
-
-
Save sweetyclem/94566c0bbc65214a792c67f31277d2af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bodyParser = require('body-parser'); | |
const subjects = require('./elements/subjects.json') | |
module.exports.listenForCommands = async function (app) { | |
app.use(bodyParser.urlencoded({ extended: true })) | |
app.use(bodyParser.json()) | |
app.post('/commands', (req, res) => { | |
const { token, user_id, channel_id } = req.body | |
console.log(`Received a slash command from user ${user_id} in channel ${channel_id}`) | |
if (token !== process.env.SLACK_VERIF_TOKEN) { | |
console.log('Invalid token') | |
return | |
} | |
res.status(200).send({ attachments: [subjects] } | |
) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment