Answer the question
In order to leave comments, you need to log in
How to add an image to a message?
There was a need for a bot that sends applications from the form to discord. I found this script online:
var POST_URL = "https://discordapp.com/api/webhooks/691027432282652682/sBGo6V4Gt_D65wAZChE-sdHeWP5t777tE8Ip-o957o7Dkv2SqfHxKzAHm1Gt49RMS";
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.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": question,
"value": parts[j],
"inline": false
});
} else {
items.push({
"name": question.concat(" (cont.)"),
"value": parts[j],
"inline": false
});
}
}
}
var options = {
"method": "post",
"headers": {
"Content-Type": "application/json",
},
"payload": JSON.stringify({
"content": "", // This is not an empty string
"embeds": [{
"title": "Уведомление о перерыве.",
"fields": items,
"footer": {
"text": "Подпись: Отдел секретариата"
}
}]
})
};
UrlFetchApp.fetch(POST_URL, options);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question