I am trying to call the constant musicSettings stored in my ready.js file however, cannot seem to export it. In my ready.js file (this needs to be in there as this is one of the only places I can access this.client)
const { Listener } = require('discord-akairo');
const { Client: Lavaqueue } = require('lavaqueue');
const { ClientID } = require('../config');
class ReadyListener extends Listener {
constructor() {
super('ready', {
emitter: 'client',
eventName: 'ready'
});
}
exec() {
process.stdout.write(`[>] Running in ${this.client.guilds.size} servers.\n`);
}
}
const musicSettings = new Lavaqueue({
userID: ClientID,
password: 'g6Z0xRLbiTHq',
hosts: {
rest: 'http://127.0.0.1:2333',
ws: 'ws://127.0.0.1:2333',
redis: { host: 'localhost' },
},
send(guildID, packet) {
this.client.ws.send(packet)
},
});
module.exports = ReadyListener;
Code located in the play.js file (does not work because I cannot import musicSettings from the ready.js file)
async exec(message, args) {
var channel = message.member.voiceChannel;
if (!channel) {
return message.reply('you need to be in a voice channel to play music.')
} else if (!args.video) {
return message.reply('you need to provide a link or search for a video.')
}
const song = await musicSettings.load(args.video);
const queue = musicSettings.queues.get(`${message.guild.id}`);
await queue.player.join(`${message.member.voiceChannel.id}`);
await queue.add(...song.tracks.map(s => s.track));
await queue.start();
}
}