client undefined

I got this code to emit a custom event in my database manager class :
console.log(this.client); <== works
this.client.emit('squadronPointsUpdate', {
squadronStats: squadronStats,
players: players,
client: this.client
});
console.log(this.client); <== works
this.client.emit('squadronPointsUpdate', {
squadronStats: squadronStats,
players: players,
client: this.client
});
It correctly logs the client in console but in my event class it logs undefined and I don't understand why
module.exports = {
name: 'squadronPointsUpdate',
async execute(squadronStats, players, client) {
console.log("\n\n")
console.log(client) <== not working "undefined"
console.log("\n\n")
console.log("hhhh")
}
module.exports = {
name: 'squadronPointsUpdate',
async execute(squadronStats, players, client) {
console.log("\n\n")
console.log(client) <== not working "undefined"
console.log("\n\n")
console.log("hhhh")
}
5 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna15mo ago
because you're passing in an object so your 'squadronStats' will have a client property players and client are undefined since they arent passed in
Cykz
CykzOP15mo ago
oh f I feel so stupid
treble/luna
treble/luna15mo ago
no worries
Cykz
CykzOP15mo ago
ohgod btw
Want results from more Discord servers?
Add your server