Play command

I am getting an error
2 Replies
optimistic-gold
optimistic-goldOP•2y ago
if (!interaction.guild) return;
if (!interaction.channel) return;
const query = interaction.options.getString('song', true);

const { voice } = interaction.member;
if (!voice.channel) return client.sendError(interaction, 'Please join an voice channel!')

const player = client.moon.players.create({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel?.id as string,
textChannel: interaction.channel.id,
autoPlay: true
});

if (!player.connected) player.connect({
setDeaf: true,
setMute: false
})

let res = await client.moon.search(query);

if (res.loadType === "LOAD_FAILED") {
return client.sendError(interaction, 'There was a problem searching!') //if there is an error when loading the tracks, it informs that there is an error
} else if (res.loadType === "NO_MATCHES") {
return client.sendError(interaction, 'There was a problem searching!')
};

if (res.loadType === 'PLAYLIST_LOADED') {
interaction.reply({
content: `${res?.playlistInfo?.name} this playlist has been added to the waiting list`
})
for (const track of res.tracks) {
//if it's a playlist it will merge all the tracks and add it to the queue
player.queue.add(track);
}
} else {
player.queue.add(res.tracks[0])
interaction.reply({
content: `${res.tracks[0].sourceName} was added to the waiting list`
})
}
if (!player.playing) player.play()
if (!interaction.guild) return;
if (!interaction.channel) return;
const query = interaction.options.getString('song', true);

const { voice } = interaction.member;
if (!voice.channel) return client.sendError(interaction, 'Please join an voice channel!')

const player = client.moon.players.create({
guildId: interaction.guild.id,
voiceChannel: interaction.member.voice.channel?.id as string,
textChannel: interaction.channel.id,
autoPlay: true
});

if (!player.connected) player.connect({
setDeaf: true,
setMute: false
})

let res = await client.moon.search(query);

if (res.loadType === "LOAD_FAILED") {
return client.sendError(interaction, 'There was a problem searching!') //if there is an error when loading the tracks, it informs that there is an error
} else if (res.loadType === "NO_MATCHES") {
return client.sendError(interaction, 'There was a problem searching!')
};

if (res.loadType === 'PLAYLIST_LOADED') {
interaction.reply({
content: `${res?.playlistInfo?.name} this playlist has been added to the waiting list`
})
for (const track of res.tracks) {
//if it's a playlist it will merge all the tracks and add it to the queue
player.queue.add(track);
}
} else {
player.queue.add(res.tracks[0])
interaction.reply({
content: `${res.tracks[0].sourceName} was added to the waiting list`
})
}
if (!player.playing) player.play()
Error: TypeError: Cannot read properties of undefined (reading 'rest')
1Lucas1.apk
1Lucas1.apk•2y ago
This error is caused when the node was not connected correctly, the node is disconnected or out of date, if it is out of date, update it, and if it did not connect, check the connection information Node information for connection*

Did you find this page helpful?