How to get access to player from different file

So I'm making a music bot and I wanted to have a slash command that makes the bot skip to the next song, but I'm having problems with getting access to the player object created in another file, what can I do? My two slash commands where one is the function that searches for a song and then plays it and the other one is to skip are in the same directory and I tried foing this:
//main command (search.js)
const player = createAudioPlayer();
module.exports = { player };
//main command (search.js)
const player = createAudioPlayer();
module.exports = { player };
//skip command (skip.js)
const { player } = require(playerPath) //playerPath is search.js
//skip command (skip.js)
const { player } = require(playerPath) //playerPath is search.js
By doing this if I try to log the player in skip.js this will print undefined.
2 Replies
d.js toolkit
d.js toolkit6mo 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
Cryingfreeman74
Cryingfreeman746mo ago
thank you