My HTML and JS script are here. The message that you get from the first textarea works but not from the text that is actually in the Modal. I am trying to use the text that is typed into the textarea by using .value, is this right? Yes, this is in a html thing and all that stuff, it is unnecessary to include that though.
<label for="contentWebhook1">Type here what you would like to send as the message (not in modal)</label>
<br>
<textarea id="contentElement" name="contentWebhook1" rows="4" cols="50"></textarea> // this works fine
<br>
<label for="titleContent2"> This is the title of the modal</label>
<br>
<textarea id="contentTitle" name="titleContent2" rows="4" cols="50"></textarea>
<br>
<label for="contentDescription">Description</label>
<br>
<textarea name="contentDescription" id="contentDescriptionWebhook" cols="50" rows="3"></textarea>
<button onclick="sendMessage()">Send message </button>
<script>
const messageContent = document.getElementById('contentElement');
const messageTitle = document.getElementById('contentTitle');
const descriptionTitle = document.getElementById('contentDescriptionWebhook');
function sendMessage() {
const request = new XMLHttpRequest;
request.open("POST", "my link here, does work");
request.setRequestHeader('Content-type', 'application/json');
const params = {
username: "",
avatar_url: "",
content: messageContent.value,
embeds: [ myEmbed ]
}
request.send(JSON.stringify(params));
}
function hexToDecimal(hex) {
return parseInt(hex.replace("#", ""), 16)
}
var myEmbed= {
author: {
name: ""
},
title: messageTitle.value,
description:descriptionTitle.value, // This goes inside modal under title ^
color: hexToDecimal("#2e5883") // This is color
}