another bot not joining the voice channel

Hi there, im learning my way through the docs and making my first bot, i was following line by line the basic example repo from discord/voice (https://github.com/discordjs/voice-examples/blob/main/basic/src/main.ts) but its not working, its basically the same code minus the formatting and the difference in current Status comparison since it seems the deesctructuring of Constants for Events, Status is not longer used... the code logs is ready to play but when i type -join on the chat it doesnt respond at all, is it because of the intents?

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildVoiceStates,
    GatewayIntentBits.GuildMessages,
  ],
});

//ready(client);

client.on("ready", async () => {
  console.log("Discord.js client is ready!");

  try {
    await playSong();
    console.log("Song is ready to play!");

  } catch (error) {
    console.error(error);
  }
});

client.on("messageCreate", async (message) => {
  if (!message.guild) return;

  if (message.content === "-join") {
    const channel = message.member?.voice.channel;

    if (channel) {
      try {
        const connection = await connectToChannel(channel);

        connection.subscribe(player);
        await message.reply("Playing now!");
      } catch (error) {
        console.error(error);
      }
    } else {
      void message.reply("Join a voice channel then try again!");
    }
  }
});


these are my dependencies

  "dependencies": {
    "@discordjs/core": "^0.6.0",
    "@discordjs/opus": "^0.9.0",
    "@discordjs/voice": "^0.16.0",
    "discord-api-types": "^0.37.43",
    "discord.js": "^14.11.0",
    "dotenv": "^16.1.4",
    "ffmpeg": "^0.0.4",
    "libsodium-wrappers": "^0.7.11",
    "nodemon": "^2.0.22",
    "sodium": "^3.0.2"
  }
GitHub
A collection of examples of how to use @discordjs/voice in your projects - voice-examples/basic/src/main.ts at main · discordjs/voice-examples
Was this page helpful?