I am trying to get input from the user and then log it to a Discord server. It normally works, but when I try to give the Modal/Embedded message a title and description through a variable that has a value from a window.prompt
it doesn’t work.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SendWebhook</title>
</head>
<body>
<button onclick="sendMessage()">Send message </button>
<script>
function sendMessage() {
var userInputLogContent = window.prompt("Enter your message (this won't affect the embedded Modal): ");
var userInputLogDescription = window.prompt("Enter whats inside the modal");
var userInputLogTitle = window.prompt("enter heading for modal");
const request = new XMLHttpRequest;
request.open("POST", "my link here, this does work ");
request.setRequestHeader('Content-type', 'application/json');
const params = {
username: "",
avatar_url: "",
content: userInputLogContent, // This works, because it isn't in the myEmbed
embeds: [ myEmbed ]
}
request.send(JSON.stringify(params));
}
function hexToDecimal(hex) {
return parseInt(hex.replace("#", ""), 16)
}
var myEmbed= {
author: {
name: ""
},
title: userInputLogTitle, // This isn't defined (according to inspect console)
description: userInputLogDescription, // Not defined (according to inspect console)
color: hexToDecimal("#2e5883") // This is color
}
</script>
</body>