├── .gitignore ├── README.md ├── package.json └── api └── heroku.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | .vercel 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord Webhooks 2 | 3 | Just Heroku for now. 4 | 5 | 6 | ## Deploy with Vercel 7 | 8 | [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fmuan%2Fdiscord-webhooks) 9 | 10 | ## Heroku 11 | 12 | 1. Deploy app and remember your `` 13 | 2. Create webhook for channel on Discord and copy `` 14 | 3. Create webhook on Heroku and use `https:///api/heroku?discord=` as the URL. 15 | 16 | Fror example: 17 | 18 | `https://very-cool-app.vercel.app/api/heroku?discord=https://discord.com/api/webhooks/00000/IOIO_Yawl7n1sOAHQ3U1` 19 | 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-webhooks", 3 | "version": "1.0.0", 4 | "description": "Parse Heroku deploy payload.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/muan/discord-webhooks.git" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/muan/discord-webhooks/issues" 18 | }, 19 | "homepage": "https://github.com/muan/discord-webhooks#readme", 20 | "dependencies": { 21 | "node-fetch": "^2.6.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/heroku.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch') 2 | module.exports = async function(req, res) { 3 | if (!req.query.discord || req.body.action !== 'create') { 4 | return res.end() 5 | } 6 | const body = { 7 | embeds: [{ 8 | title: `[${req.body.data.app.name}] ${req.body.data.description}`, 9 | description: req.body.data.slug.commit_description, 10 | color: 7419530 11 | }] 12 | } 13 | await postTo(req.query.discord, body) 14 | res.end() 15 | } 16 | 17 | async function postTo(url, body) { 18 | return fetch(url, { 19 | method: 'POST', 20 | body: JSON.stringify(body), 21 | headers: {'Content-Type': 'application/json'} 22 | }) 23 | } 24 | --------------------------------------------------------------------------------