-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (62 loc) · 2.52 KB
/
index.html
File metadata and controls
72 lines (62 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Submit to Discord</title>
<style>
body { font-family: Arial, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; }
textarea { width: 100%; height: 150px; padding: 10px; }
button { background: #5865F2; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
#status { margin-top: 20px; font-weight: bold; }
</style>
</head>
<body>
<h1>Submit Message to Discord</h1>
<form id="discordForm">
<label for="message">Your message (prefilled or custom):</label><br><br>
<textarea id="message" name="message" placeholder="Type your message here..." required>
Bug report: Describe the issue here...</textarea><br><br>
<button type="submit">Send to Discord Channel</button>
</form>
<div id="status"></div>
<script>
const form = document.getElementById('discordForm');
const status = document.getElementById('status');
// === CHANGE THIS TO YOUR ACTUAL WORKER URL ===
const WORKER_URL = 'https://color-vault-relay.glwplex-7c2.workers.dev';
form.addEventListener('submit', async (e) => {
e.preventDefault(); // Prevents default form submission (critical!)
status.textContent = 'Sending...';
status.style.color = 'blue';
const formData = new FormData(form);
try {
const response = await fetch(WORKER_URL, {
method: 'POST',
body: formData
});
// Check if response is ok before parsing JSON
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Server error ${response.status}: ${errorText}`);
}
const result = await response.json();
if (result.success) {
status.textContent = 'Message sent to Discord successfully!';
status.style.color = 'green';
form.reset();
// Restore prefilled text after reset (optional)
document.getElementById('message').value = 'Bug report: Describe the issue here...';
} else {
status.textContent = 'Error: ' + (result.error || 'Unknown error');
status.style.color = 'red';
}
} catch (err) {
console.error('Fetch error:', err);
status.textContent = 'Failed to send: ' + err.message;
status.style.color = 'red';
}
});
</script>
</body>
</html>