Discord Webhook与Google表格

时间:2017-09-19 16:36:57

标签: javascript google-docs webhooks discord

好的,我有一个discord服务器并用webhook设置它。我希望用户输入google表单并让响应进入不和谐服务器

以下是我给出的内容:

function onFormSubmit(e) {
var fields = [];

for (i = 0; i < e.response.getItemResponses().length; i++) {
    var response = e.response.getItemResponses()[i];
    fields.push({
        "name": response.getItem().getTitle(),
        "value": response.getResponse(),
        "inline": false
    });
}

var data = {
    "embeds": [{
        "title": "**New form submission** — " + (e.source.getTitle() != null && e.source.getTitle().length > 0 ? e.source.getTitle() : "Untitled Form"),
        "type": "rich",
        "fields": fields
    }]
};

var options = {
    method: "post",
    payload: JSON.stringify(data),
    contentType: "application/json; charset=utf-8",
    muteHttpExceptions: true
};

Logger.log("Attempting to send:");
Logger.log(JSON.stringify(data));

var response = UrlFetchApp.fetch("DISCORD WEBHOOK URL GOES HERE", options);
Logger.log(response.getContentText());
};

我的表单有7个字段:Discord用户名,类型,成员,游戏,说明,时间戳和剪辑URL。

我很难理解我如何在我的代码中使用这些字段,并且感谢任何帮助。

0 个答案:

没有答案