-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.js
53 lines (43 loc) · 1.23 KB
/
update.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const axios = require('axios');
const fs = require('fs');
const mustache = require('mustache');
const mustache_template = './README.mustache';
const base_url = "https://evoke.nitro-cpanel.xyz";
const url = base_url + "/api/top/16";
const data = {};
const time = new Date().toLocaleDateString('en-GB', {
weekday: 'long',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
timeZoneName: 'short',
timeZone: 'Europe/Stockholm',
});
function chunk(array, size) {
const results = [];
while(array.length) {
results.push(array.splice(0, size));
}
return results;
}
async function generate_readme() {
let response = await axios.get(url);
data.time = time;
response = response.data;
Array.from(response).forEach((emote, i) => {
let url = emote.urls.split(",")[0];
if(url.startsWith("//")) {
url = "https:" + url;
}
response[i].url = url;
});
const emotes = chunk(response, 4);
data.emotes = emotes;
fs.readFile(mustache_template, (err, result) => {
if (err) throw err;
const output = mustache.render(result.toString(), data);
fs.writeFileSync('README.md', output);
});
}
generate_readme();