Webhook added, gonna brush up on it later

This commit is contained in:
IM23a-bachmannj2
2024-09-15 20:10:53 +02:00
parent 0b043398db
commit 91cfce7030
2 changed files with 36 additions and 6 deletions
+4
View File
@@ -224,4 +224,8 @@ nav {
font-size: 16px; font-size: 16px;
} }
}
.button1 {
background-color: black;
} }
+32 -6
View File
@@ -52,7 +52,7 @@
<main class="background-image"> <main class="background-image">
<h1>Suggestion</h1> <h1>Suggestion</h1>
<h3 class="suggestion-title"><b>Welcome to Suggestions!</b><br> We encourage you to share your ideas, improvments, or even fun comments with us, so we can develop this website further.</h3> <h3 class="suggestion-title"><b>Welcome to Suggestions!</b><br> We encourage you to share your ideas, improvments, or even fun comments with us, so we can develop this website further.</h3>
<form action=""> <article>
<label for="name">Pseudoname:</label> <label for="name">Pseudoname:</label>
<input type="text" id="name" name="name" placeholder="not required"><br><br> <input type="text" id="name" name="name" placeholder="not required"><br><br>
@@ -60,11 +60,37 @@
<input type="number" id="rate" name="rating" min="1" max="10" required><br><br> <input type="number" id="rate" name="rating" min="1" max="10" required><br><br>
<label for="text">Text:</label> <label for="text">Text:</label>
<textarea id="text" name="text" rows="4" cols="50" placeholder="Enter your comments here..." minlength="5" maxlength="250" required></textarea><br><br> <textarea id="text" name="text" rows="4" cols="50" placeholder="Enter your comments here..." minlength="5" maxlength="500" required></textarea><br><br>
</article>
<input type="submit" value="Submit"> <button class="button1" type="button" onclick="sendMessage()">Send</button>
<input type="reset" value="Reset">
</form>
</main> </main>
<script>
function sendMessage() {
const request = new XMLHttpRequest();
request.open("POST", "https://discord.com/api/webhooks/1284936894890901649/Zi-2ZV12L1v1OSBoM-DluE1V1LECXilrNNRZYJcxelnwO7rGgXNH47dxvfFEOK7Fe9_J");
request.setRequestHeader('Content-type', 'application/json');
// Get the values from the input fields
const pseudoname = document.getElementById("name").value || "Anonymous";
const rating = document.getElementById("rate").value;
const comment = document.getElementById("text").value;
// Create the content to send to the Discord webhook
const content = `**Pseudoname:** ${pseudoname}\n**Rating:** ${rating}\n**Comment:**\n${comment}`;
// Debugging information
console.log('Sending message with content:', content);
// Send the message payload to the Discord webhook
const params = {
username: pseudoname, // Pseudoname will appear as the username
content: content // The combined content (pseudoname, rating, and comment)
};
request.send(JSON.stringify(params));
}
</script>
</body> </body>
</html> </html>