webhook/test/WebhookClient.test.js
2023-04-12 16:37:37 +03:00

40 lines
1.5 KiB
JavaScript

import { WebhookClient } from '../build/index.js';
import EventEmitter from "events";
const webhook = new WebhookClient({ url: 'https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn' });
// new WebhookClient({ token: 'uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn', id: '1093874668886294548' });
// new WebhookClient({
// id: '1093874668886294548',
// token: 'uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn',
// url: 'https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn'
// });
// new WebhookClient({
// id: '1093874668886294548',
// url: 'https://discord.com/api/webhooks/1093874668886294548/uDMRD6g1lmq_2EZynsbKytzWoMM-0N4te0m61r_cv1BsSnDKDxG3fvI6sxSoG5t5b_xn'
// });
// new WebhookClient({
// id: '1093874668886294548'
// });
webhook.on('rateLimited', () => console.log('Webhook was rate limited'));
console.log(await webhook.fetch());
const promises = [];
for (let i = 0; i < 15; i++)
promises.push(webhook.send(`Test ${i}`));
console.log('promises', await Promise.all(promises));
// const promise = new Promise((resolve) => {
// setTimeout(resolve, 5000);
// });
// const emitter = new EventEmitter();
// emitter.on('event', async () => {
// await promise;
// console.log('Done');
// });
// for (let i = 0; i < 5; i++) {
// emitter.emit('event');
// console.log('Emitted');
// }