This repository was archived by the owner on Jul 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.gs
More file actions
52 lines (46 loc) · 1.55 KB
/
System.gs
File metadata and controls
52 lines (46 loc) · 1.55 KB
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
var POST_URL = "WEBHOOK_URL"; //put your discord Webhook URL here
function onSubmit(_) {
var allResponses = FormApp.getActiveForm().getResponses();
var response = allResponses[allResponses.length - 1].getItemResponses();
var items = [];
for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
try {
var parts = answer.match(/[\s\S]{1,1024}/g) || [];
} catch (e) {
var parts = answer;
}
if (answer == "") {
continue;
}
for (var j = 0; j < parts.length; j++) {
if (j == 0) {
items.push({
"name": "**" + (j == 0 ? question : question.concat(" (cont.)")) + "**" ,
"value": "\`\`\`▶️ | " + parts[j] + "\`\`\`",
"inline": false
});
}
}
}
//"\`\`\`" + + "\`\`\`"
var options = {
"method": "post",
"headers": {
"Content-Type": "application/json",
},
"payload": JSON.stringify({
"content": " CONTENT HERE ", // put your Content here
"embeds": [{
"title": " TITLE HERE ", // Put your Title here
"color": 7506394,
"fields": items,
"footer": {
"text": "FOOTER HERE" //Put Footer here
}
}]
})
};
UrlFetchApp.fetch(POST_URL, options);
};