0

我需要帮助,我的 Webhook 没有回复 Discord 以发布日志消息。这是代码,出于安全原因,我删除了一些代码..

<?php
        ?>
        <script type="text/javascript">
function sendLog(){ 
    tosend = [
    '**Server added;**',
    'Game Name: <?php echo(json_encode($name)); ?>',
    'Game ID: <?php echo(json_encode($gid)); ?>',
    'Server ID: <?php echo(json_encode($sid)); ?>',
    ],
    msgJson = {
         "attachments": [
        {
            "color": "#CC09EF",
            "text": tosend.join('\n'),
            "footer": "Infius Game Logs",
            "footer_icon": "http://deersystems.net/assets/images/nfius.png",
        }
    ]
        }
  post(hookurl, msgJson); 
  }

function post(url, jsonmsg){
    xhr = new XMLHttpRequest();
    xhr.open("POST", url, true);
    xhr.setRequestHeader("Content-type", "application/json");
    var data = JSON.stringify(jsonmsg);
    xhr.send(data);
    xhr.onreadystatechange = function() {
        if(this.status != 200){
            alert("ttt");
        }
    }
}
</script>

<?php
        if($token == '*****'){
        $con = mysqli_connect("localhost","8888888");

        if(mysqli_connect_errno()){
            echo(mysqli_connect_error());
        }
        } elseif($type == 'add' and $sid !=NULL and $gid !=NULL and $name!=NULL and $players !=NULL){
        ?>
        <script type="text/javascript">
                sendLog();
        </script>
        <?php

} else {

echo"<script type=\"text/javascript\">
    sendLog();
    </script>";
}
    ?>

我不认为这个函数是用 http Post Async 调用的,或者 Js 没有加载。

4

0 回答 0