forked from sylveon/discord-ban-appeals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
55 lines (49 loc) · 1.63 KB
/
build.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
54
55
const Discord = require("discord.js");
const fs = require("fs");
const path = require("path");
const process = require("process");
async function main() {
if (!process.env.USE_NETLIFY_FORMS) {
const submissionOldFunction = path.resolve(__dirname, "func", "submission-created.js");
const submissionNewFunction = path.resolve(__dirname, "func", "submit-appeal.js");
fs.rename(submissionOldFunction, submissionNewFunction, err => {
if (err) {
console.log(err);
process.exit(1);
}
});
const form = path.resolve(__dirname, "public", "form.html");
fs.readFile(form, "UTF-8", (err, data) => {
if (err) {
console.log(err);
process.exit(1);
}
data = data.replace("action=\"/success\" netlify", "action=\"/.netlify/functions/submit-appeal\"");
fs.writeFile(form, data, "UTF-8", err => {
if (err) {
console.log(err);
process.exit(1);
}
});
});
}
if (process.env.DISABLE_UNBAN_LINK) {
const unban = path.resolve(__dirname, "func", "unban.js");
fs.unlink(unban, err => {
if (err) {
console.log(err);
process.exit(1);
}
});
}
// Make sure the bot connected to the gateway at least once.
const client = new Discord.Client();
try {
await client.login(process.env.DISCORD_BOT_TOKEN);
} catch (e) {
console.log(e);
process.exit(1);
}
client.destroy();
}
main();