async function displayEmbed(args, msg) {
var bridgeembed = await getBridgeClutcherStats(args, msg) //should set bridgeembed to an embed
var omniembed = await getOmniClutcherStats(args, msg) //should set omniembed to an embed
var extembed = await getExtClutcherStats(args, msg) //should set extembed to an embed
var desccc = "```Bridge Clutch: ```\n" + "```Omni Clutch: ⚛```\n" + "```Extension Clutch: ```\n";
new Menu(msg.channel, msg.author.id, [{
name: "main",
content: new MessageEmbed({
title: "Please Choose a Gamemode",
description: desccc,
url: "https://3d4h.world",
color: 16711935,
author: {
name: args[1],
url: `https://namemc.com/profile/${args[1]}`,
icon_url: `https://mc-heads.net/body/${args[1]}`
}
}),
reactions: {
"": "stop",
"": "bridgeclutch",
"⚛": "omniclutch",
"": "extclutch"
}
},
{
name: "bridgeclutch",
content: bridgeembed,
reactions: {
"◀": "main"
},
name: "omniclutch",
content: omniembed,
reactions: {
"◀": "main"
},
name: "extclutch",
content: extembed,
reactions: {
"◀": "main"
}
}
]);
}
So I've been trying to have three functions run before I create an embed menu. I followed these (How to synchronously call a set of functions in javascript) steps but bridgeembed, omniembed, and extembed still ended up as undefined.
When I directly sent the embed from the functions, it worked. I also tried using callbacks like this:
getOmniClutcherStats(args, msg, function(omniclutchEmbed){
getExtClutcherStats(args, msg, function(extclutchEmbed){
getBridgeClutcherStats(args, msg, function(bridgeclutchEmbed) {
new Menu(msg.channel, msg.author.id, [{
name: "main",
content: new MessageEmbed({
title: "Please Choose a Gamemode",
description: desccc,
url: "https://3d4h.world",
color: 16711935,
author: {
name: args[1],
url: `https://namemc.com/profile/${args[1]}`,
icon_url: `https://mc-heads.net/body/${args[1]}`
}
}),
reactions: {
"": "stop",
"": "bridgeclutch",
"⚛": "omniclutch",
"": "extclutch"
}
},
{
name: "bridgeclutch",
content: bridgeembed,
reactions: {
"◀": "main"
},
name: "omniclutch",
content: omniembed,
reactions: {
"◀": "main"
},
name: "extclutch",
content: extembed,
reactions: {
"◀": "main"
}
}
]);
});
});
});
But only when getting bridgeembed it worked, for the others UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'content' of undefined
How can I save the returned or callbacked embeds to variables so I can access them in the reaction menu?
Thanks in advance!