Discord.JS not producing any sound

got stuck here, the bot seems to do exactly what I want but it does not produce any sound, it shows the song but just no sound. I put GatewayIntentBits.GuildVoiceStates in the Client instance, I also did selfMute : false.

export async function execute(interaction: CommandInteraction) {
  const player = useMainPlayer();
  player.extractors.register(YouTubeExtractor, {});
  player.extractors.register(SpotifyExtractor, {});

  if (!interaction.guildId || !interaction.member) {
    await interaction.reply("You must be in a guild to use this command");
    return;
  }

  const guildId = interaction.guildId;
  const member = interaction.member as GuildMember;
  const voiceChannel = member.voice.channel;

  if (!voiceChannel) {
    await interaction.reply(
      "You must be in a voice channel to use this command."
    );
    return;
  }

  const options = interaction.options as CommandInteractionOptionResolver;
  const subcommand = options.getSubcommand();
  const query = options.getString("url") || options.getString("searchterms");

  if (!query) {
    await interaction.reply("You must provide a query.");
    return;
  }
  const adapterCreator = interaction.guild
    ?.voiceAdapterCreator as DiscordGatewayAdapterCreator;
  if (!adapterCreator) {
    await interaction.reply("Failed to get the voice adapter creator.");
    return;
  }

  const connection = joinVoiceChannel({
    channelId: voiceChannel.id,
    guildId: guildId,
    adapterCreator: adapterCreator,
  });

  const audioPlayer = createAudioPlayer();
  connection.subscribe(audioPlayer);

  connection.on(VoiceConnectionStatus.Ready, () => {
    console.log(`The Bot has connected to the channel`);
  });
  connection.on(VoiceConnectionStatus.Disconnected, async () => {
    try {
      await Promise.race([
        entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
        entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
      ]);
    } catch (error) {
      connection.destroy();
    }
  });

  const queue =
    player.nodes.get(guildId) ||
    player.nodes.create(guildId, {
      metadata: {
        channel: interaction.channel,
      },
    });

  if (!queue.connection) {
    await queue.connect(voiceChannel);
    return;
  }

  await interaction.reply(`Searching for ${query}`);

  try {
    let result;
    if (subcommand == "song" || subcommand == "search") {
      result = await player.search(query, {
        requestedBy: member,
        searchEngine: QueryType.AUTO,
      });
    } else if (subcommand == "playlist" || result) {
      result = await player.search(query, {
        requestedBy: member,
        searchEngine: QueryType.YOUTUBE_PLAYLIST,
      });
    }

    console.log("Search result: ", result);

    if (!result || !result.tracks.length) {
      await interaction.editReply("No results found.");
      return;
    }

    const track = result.tracks[0];
    if (track) {
      const stream = ytdl(track.url, {
        filter: "audioonly",
        highWaterMark: 1 << 25,
      });
      const resource = createAudioResource(stream);
      audioPlayer.play(resource);
      audioPlayer.on(AudioPlayerStatus.Playing, () => {
        console.log(`Audio Player started playing...`);
      });
      audioPlayer.on(AudioPlayerStatus.Idle, () => {
        console.log(`Audio Player is idle...`);
      });
      audioPlayer.on("error", (error) => {
        console.error(
          `Error: ${error.message} with resource ${error.resource.metadata}`
        );
        interaction.followUp({
          content: "Error occured during playback",
          ephemeral: true,
        });
      });
      await interaction.editReply(`Now playing : ${track.title}`);
    }
  } catch (error) {
    console.error("Error during search and playback: ", error);
    await interaction.editReply(
      "An error occurred while trying to play the track."
    );
  }
}




I gave it the proper permissions (CONNECT,SPEAK) still no sound and

here’s also my client instance

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

installed dependencies

    "@discord-player/extractor": "^4.4.7",
    "@discordjs/voice": "^0.17.0",
    "discord-player": "^6.6.8",
    "discord.js": "^14.15.2",
    "ytdl-core": "^4.11.5"
    "opusscript": "^0.0.8",
    "ffmpeg-static": "^5.2.0",

New contributor

Brent V is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật