var webhook_array = webhook_url.split(",");
console.log(webhook_array);
function send(item) {
console.log(item)
request.open("POST", item);
request.setRequestHeader('Content-type', 'application/json');
var myEmbed = {
title: embed_title,
color: hexToDecimal(hexcolour),
description: message_content,
footer: {
text: "Powered by Yapplex Tools",
icon_url: avatarurl,
}
}
var params = {
username: webhook_username,
avatar_url: avatarurl,
embeds: [ myEmbed ]
}
request.send(JSON.stringify(params));
}
webhook_array.forEach(send);
function hexToDecimal(hex) {
return parseInt(hex.replace("#",""), 16)
}
}
This code should go through each webhook in the array and send a message using them. It prints them to console meaning that they are there and that it can detect them, but only one of the webhooks is called(when tested using two webhooks)
async/awaitand wait for each http operation to complete before moving on to the next one. Usually with async await patterns it's not a good idea to use forEach. Instead, wrap the entire code in an anonymousasyncfunction, and to loop through each web_hook with aforloop using await on each function call. Also, assumingrequestis an XHR object, you may consider usingfetchAPI instead, since you can useawaiton them. If you are having difficulty in understanding, I can write the code as well.