-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (30 loc) · 859 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const Xray = require("x-ray");
const x = Xray();
const request = require("request");
const githubName = "XXXXXXXXXXXXXXXXXXXX";
const githubUrl = `https://github.com/users/${githubName}/contributions`;
const discordWebhook = "XXXXXXXXXXXXXXXXXXXX";
exports.handler = function(event, context) {
x(githubUrl, "rect", [{ count: "@data-count" }])((error, result) => {
if (error) {
console.log(error);
} else {
const contributions_result = result[result.length - 1].count;
request.post(
{
url: discordWebhook,
form: {
content: `Today's contributions is ${contributions_result}times`
}
},
function(err, response, body) {
if (err) {
console.log(err);
} else {
console.log(body);
}
}
);
}
});
};