Added Discord webhook

This commit is contained in:
Lexi Sother 2021-03-02 15:57:58 +00:00
parent e8bd529ec9
commit 7e9d5bbafa
2 changed files with 47 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import ModuleRepos from './modules/index.js';
import AutoTag from './autoTag.js';
import WebhookSend from './webhook.js';
import Parcel from 'parcel-bundler';
import axios from 'axios';
@ -206,3 +207,5 @@ for (const parentRepo of ModuleRepos) {
writeFileSync(`${distDir}/modules.json`, JSON.stringify(oldTotalModulesJson));
copyFileSync(`${__dirname.replace('/src', '')}/_headers`, `${distDir}/_headers`);
WebhookSend();

44
src/webhook.js Normal file
View File

@ -0,0 +1,44 @@
import * as https from 'https';
export default () => {
const data = JSON.stringify({
username: 'NovaStore',
embeds: [
{
title: 'Module Store Updated',
url: 'https://goose.lexisother.tk/nova.json',
timestamp: new Date(),
author: {
name: 'Nova Module Store',
icon_url: 'https://goosemod.com/img/logo.jpg',
},
},
],
});
const options = {
hostname: 'discord.com',
path: `/api/webhooks/816327784121106452/${process.env.HOOKTOKEN}`,
port: 443,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
},
};
const req = https.request(options, (res) => {
console.log(`Status code: ${res.statusCode}`);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.on('error', (err) => {
console.error(err);
});
req.write(data);
req.end();
};