discord.js shard.broadcastEval async

I'm having an issue with implementing sharding into my bot

This returns correct:

await (async () => {
    return "test3";
}).call()

but once i shard it like this:

client.shard.broadcastEval(`
    await (async () => {
        return "test3";
    }).call()            
`)

it errors with ReferenceError: await is not defined

So this might not even be the correct way to do what i want.. What I'm trying to do is get all the guilds a user is an administrator of or has a certain role, I've already written the script, my issues is i can't get the response due to the await issue above.

2 answers

  • answered 2019-03-14 07:41 Igor Litvinovich

    You don't have use async/await in your case. you can just simply return promise from the function.

    client.shard.broadcastEval(`
        (() => {
            return Promise.resolve("test3");
        }).call()            
    `)
    

    Hope it helps.

  • answered 2019-03-14 08:06 Ömür Alçin

    Your code should be like this :

    client.shard.broadcastEval(`
        (async => { 
            return "test3";
        })();
    `);
    

    Check from here : Discord.js Guide