Repository: discordjs/discord.js

Issue #7006: Random Undefined Error | Library Issue
Created: 2021-11-19T03:42:57Z
Issue description
I have recently encountered an error while updating from v12 to v13,
I am not sure how to reproduce the error as none of my code has been referenced in the error nor am i sure what causes this error to be thrown.
I have been told that it could be due to my sharding file so i have put that down below.
Code sample
Error Code:

Error [ReferenceError]: res is not defined
    at eval (eval at _eval (C:\Users\OneDrive\Desktop\Spixx d.js v13\node_modules\discord.js\src\client\Client.js:534:12), <anonymous>:1:35)
    at eval (eval at _eval (C:\Users\OneDrive\Desktop\Spixx d.js v13\node_modules\discord.js\src\client\Client.js:534:12), <anonymous>:1:68)
    at Client._eval (C:\Users\OneDrive\Desktop\Spixx d.js v13\node_modules\discord.js\src\client\Client.js:534:12)
    at ShardClientUtil._handleMessage (C:\Users\OneDrive\Desktop\Spixx d.js v13\node_modules\discord.js\src\sharding\ShardClientUtil.js:184:82)
    at process.emit (node:events:402:35)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

Sharding Manager:

const { ShardingManager } = require('discord.js');
const Discord = require('discord.js');
const config = require('./config.json');
const manager = new ShardingManager('./bot.js', { 
    token: config.token
});
const webhookClient = new Discord.WebhookClient({id: config.id, token: config['web-token']});

manager.on('shardCreate', shard => {
    console.log(`Launched shard ${shard.id}`)
    
    const embed = new Discord.MessageEmbed()
	.setTitle(`Shard ${shard.id} has launched.`)
    .setTimestamp()

    webhookClient.send({
        username: `Shard ${shard.id} Launched`,
        embeds: [embed]
    })
})

manager.spawn({ amount: config.ShardCount, delay: 5000});
discord.js version
13.3.1
Node.js version
16.11.1
Operating system
windows
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
USER, CHANNEL, GUILD_MEMBER, MESSAGE
Which gateway intents are you subscribing to?
GUILDS, GUILD_MEMBERS, GUILD_BANS, GUILD_EMOJIS_AND_STICKERS, GUILD_INTEGRATIONS, GUILD_WEBHOOKS, GUILD_INVITES, GUILD_VOICE_STATES, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS, DIRECT_MESSAGE_TYPING
I have tested this issue on a development release
No response

Duplicate issue #7024: ShardClientUtil#broadcastEval outputs `〇〇 is not defined` error for out of scope variables
Created: 2021-11-23T02:45:41Z
Issue description
If you run broadcastEval with an out-of-scope variable in a bot that is sharding, it will output an error.
Code sample
const sampleValue = "Dummy";
client.shard.broadcastEval((cl) => cl.users.cache.find(x => x.username == sampleValue)); //sampleValue is not defined
discord.js version
13.3.1
Node.js version
16.13.0
Operating system
Replit
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
USER, CHANNEL, GUILD_MEMBER, MESSAGE, REACTION
Which gateway intents are you subscribing to?
GUILDS, GUILD_MEMBERS, GUILD_BANS, GUILD_EMOJIS_AND_STICKERS, GUILD_INTEGRATIONS, GUILD_WEBHOOKS, GUILD_INVITES, GUILD_VOICE_STATES, GUILD_PRESENCES, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS, DIRECT_MESSAGE_TYPING
I have tested this issue on a development release
No response

Closing comment (2021-11-23T03:50:30Z): duplicate #7006