-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.readme.js
47 lines (46 loc) · 1.59 KB
/
generate.readme.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
const { AppConfig } = require('./app.config');
const fs = require('fs');
const { HelpCommand } = require('./src/engine/commands/help.command');
const { LiteralConstants } = require('./src/utils/literal.constants');
async function main(){
const dummyConfig = {
CONFIG_STORAGE: {
getProperty(guild, prop){
return '!'
}
},
COMMANDS: AppConfig.COMMANDS,
PERMISSIONS: AppConfig.PERMISSIONS,
DISCORD_HELPERS: {
generateEmbed(content){
return content;
}
}
}
let helpText;
const dummyMessage = {
channel: {
send(content){
helpText = content;
}
}
}
let template = String(fs.readFileSync('./readme.template.md'));
let output = '';
const commands = AppConfig.COMMANDS(dummyConfig).sort((a, b) => {
return a.aliases[0].localeCompare(b.aliases[0]);
});
const help = HelpCommand(dummyConfig);
for(command of commands){
await help.callback(dummyMessage, [command.aliases[0]]);
output = output + `### \`${command.aliases[0]}\`\n\n`
for(field of helpText.embeds[0].fields){
output = output + `${field.name}\n\n${field.value.replaceAll('\n', '\n\n').replaceAll(' ', '').trim()}\n\n`;
}
}
template = template.replace('${COMMANDS}', output);
template = template.replace('${OFFLINE}', LiteralConstants.OFFLINE_EMOJI);
template = template.replace('${ONLINE}', LiteralConstants.ONLINE_EMOJI);
fs.writeFileSync('./readme.md', template);
}
main();