-
Notifications
You must be signed in to change notification settings - Fork 0
/
disord.js
33 lines (28 loc) · 1.02 KB
/
disord.js
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
(async () => {
const fetch = (await import('node-fetch')).default;
const webhookURL = 'https://discord.com/api/webhooks/1274660391288573972/JttFmAu7-i0kkj4584Voa6klmsVqm01XsK7bsTSwDSLPovm_rVjsyRXmvFgfLSK3hzhY';
const payload = {
content: 'Hello, this is a test message from the webhook!',
username: 'Webhook Bot',
avatar_url: 'https://example.com/avatar.png',
};
async function sendMessage() {
try {
const response = await fetch(webhookURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
if (response.ok) {
console.log('Message sent successfully!');
} else {
console.error('Failed to send message:', response.statusText);
}
} catch (error) {
console.error('Error sending message:', error);
}
}
sendMessage();
})();