/play command not working

client.commands = new Map();
client.commands.set("play", async (message) => {
if (message.content.startsWith("/play")) {
const query = message.content.slice(6);
const track = query; // Replace this with your own logic to resolve the track

if (track) {
const voiceChannel = message.member.voice.channel;

if (voiceChannel) {
try {
const connection = await voiceChannel.join();
connection.play(track);
message.reply(Now playing: ${track});
} catch (error) {
console.error(error);
message.reply("An error occurred while playing the track.");
}
} else {
message.reply("You must be in a voice channel to play music.");
}
} else {
message.reply("Could not find track.");
}
}
});
THis is not showing /play command in the command list
Was this page helpful?