Closed Spencer-0003 closed 3 years ago
No, Erela is ok. Are you sure, the problem is caused by this code?
As far as I can tell, yeah. Lavalink returns the tracks with no issues but when I try to connect the player it just errors
Then show me code before this, because this should work fine
This is the code for my play command at the moment.
const Command = require("@structures/Command");
// const createEmbed = require("@utils/CreateEmbed");
module.exports = class PlayCommand extends Command {
constructor(client) {
super(client, {
name: "play",
aliases: ["p_new"], // Will be changed to "p" later.
group: "music",
memberName: "play",
description: "Plays the chosen song.",
guildOnly: true
});
};
async run(message) {
let searchString = message.content.split(/\s+/g).slice(1).join(" ");
let player = this.client.elera.create({
guild: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
volume: 10,
selfDeafen: true
});
player.connect();
let res;
try {
res = await this.client.elera.search(searchString, message.author);
if (res.loadType === "LOAD_FAILED") {
throw res.exception;
} else if (res.loadType === "PLAYLIST_LOADED") {
res.tracks.forEach(track => player.queue.add(track));
} else if (res.loadType === "SEARCH_RESULT") {
player.queue.add(res.tracks[0]);
};
} catch (err) {
return message.reply(`There was an error while searching: ${err.message}`);
};
if (res.loadType === "NO_MATCHES") return message.reply("There was no tracks found with that query.");
if (!player.playing && !player.paused && !player.queue.size) {
player.play();
};
};
};
Hm, I can't see any problems here. btw u can do
else if (res.loadType === "PLAYLIST_LOADED") {
player.queue.add(res.tracks);
}
What is in @structures/Command file?
This is my command file.
const { Command } = require("discord.js-commando");
module.exports = class AshlynCommand extends Command {
constructor(client, info) {
super(client, info);
this.throttling = info.unknown ? null : info.throttling || { usages: 1, duration: 2 };
};
};
This is the code that is causing the issue:
When player.connect is called, my bot errors with this
TypeError: Cannot read property 'cache' of undefined
. I don't reference cache anywhere so I think it's an issue with Erela?