Pass variables into <ShardingManager>.broadcastEval

I have this code:
const params = {
guild_id: "",
channel_id: "",
shard_id: 0
}

// @ts-ignore
const result = await manager.broadcastEval(async (client: CustomClient) => {
const guild = client.guilds.cache.get(params.guild_id)
const channel = guild?.channels.cache.get(params.channel_id);

return channel?.id

}, { shard: params.shard_id });

console.log(result);
const params = {
guild_id: "",
channel_id: "",
shard_id: 0
}

// @ts-ignore
const result = await manager.broadcastEval(async (client: CustomClient) => {
const guild = client.guilds.cache.get(params.guild_id)
const channel = guild?.channels.cache.get(params.channel_id);

return channel?.id

}, { shard: params.shard_id });

console.log(result);
But i get the following error when i run this code:
Error [ReferenceError]: msg is not defined
at eval (eval at _eval (/media/cleiton/Arquivos/Pastas/Documentos/Projetos/bot/api/node_modules/discord.js/src/client/Client.js:482:12), <anonymous>:2:55)
Error [ReferenceError]: msg is not defined
at eval (eval at _eval (/media/cleiton/Arquivos/Pastas/Documentos/Projetos/bot/api/node_modules/discord.js/src/client/Client.js:482:12), <anonymous>:2:55)
So i want to know... How can i pass the variable params to the broadcastEval? With the vanilla javascript eval i can pass the variables into strings, but how can i do in shardingManager?
3 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
José
JoséOP2y ago
npm list discord.js => [email protected] node -v => v18.16.1
José
JoséOP2y ago
i read the docs searching for somethind, and i find the context option, but how can i read that?
Want results from more Discord servers?
Add your server