Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将webhook发送到与.js不一致的地方_Javascript_Html_Discord - Fatal编程技术网

Javascript 将webhook发送到与.js不一致的地方

Javascript 将webhook发送到与.js不一致的地方,javascript,html,discord,Javascript,Html,Discord,您好,我想使用webhooks将inputValue发送到discord。代码如下: 我想发送一条不一致的消息[使用webhooks],其中包含以下inputValue 我把//Send discord webhook和inputValue放在代码应该在的地方,并尝试了一些方法,但没有成功;(: $(function () { function display(bool) { if (bool) { $("#container"

您好,我想使用webhooks将inputValue发送到discord。代码如下: 我想发送一条不一致的消息[使用webhooks],其中包含以下inputValue 我把//Send discord webhook和inputValue放在代码应该在的地方,并尝试了一些方法,但没有成功;(:

$(function () {
    function display(bool) {
        if (bool) {
            $("#container").show();
        } else {
            $("#container").hide();
        }
    }

    display(false)

    window.addEventListener('message', function(event) {
        var item = event.data;
        if (item.type === "ui") {
            if (item.status == true) {
                display(true)
            } else {
                display(false)
            }
        }
    })
    // if the person uses the escape key, it will exit the resource
    document.onkeyup = function (data) {
        if (data.which == 27) {
            $.post('http://nui2/exit', JSON.stringify({}));
            return
        }
    };
    $("#close").click(function () {
        $.post('http://nui2/exit', JSON.stringify({}));
        return
    })
    //when the user clicks on the submit button, it will run
    $("#submit").click(function () {
        let inputValue = $("#input").val()
        if (inputValue.length >= 100) {
            $.post("http://nui2/error", JSON.stringify({
                error: "The maximum number of characters is 100" // Error message to chat
            }))
            return
        } else if (!inputValue) {
            $.post("http://nui2/error", JSON.stringify({
                error: "You didn't complete the box" // Error message to chat
            }))
            return
        }
        // if there are no errors from above, we can send the data back to the original callback and hanndle it from there
        $.post('http://nui2/main', JSON.stringify({
            text: inputValue, // Send text to chat

           // send discord webhook with inputValue

        }));
        return;
    })
})