webhook/test/WebhookClient.test.js

50 lines
1.7 KiB
JavaScript

import WebhookClient from '../build/esm/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());
await webhook.send({
content: 'Hi',
embeds: [{
title: 'Embed test',
description: 'Bingus'
}]
});
const promises = [];
for (let i = 0; i < 15; i++)
await webhook.send(`Test ${i}`);
// promises.push();
console.log('Loop done');
// console.log('promises', await Promise.all(promises));
console.log('end');
// 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');
// }