Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
discordjs/voice simple request help for works

(sry for my English) I just want to make a simple reaction message, connection to vocal where user use one word as "exemple" in this "it is an exemple", and play one song.mp3, after the bot deconnect when he finish this song.mp3.

This is my index.js

const { Client, VoiceChannel, Intents } = require('discord.js');
const client = new Client({ intents: 32767 });
const dotenv = require('dotenv'); dotenv.config();
const {
    joinVoiceChannel,
    createAudioPlayer,
    createAudioResource,
    entersState,
    StreamType,
    AudioPlayerStatus,
    VoiceConnectionStatus,
} = require ('@discordjs/voice');
const { createDiscordJSAdapter } = require ('./?');
const player = createAudioPlayer();

client.login(process.env.DISCORD_TOKEN);

function playSong() {
    const resource = createAudioResource('./music/try.mp3', {
          inputType: StreamType.Arbitrary,
      });
    player.play(resource);
    return entersState(player, AudioPlayerStatus.Playing, 5e3);
  };

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);
    }
});

async function connectToChannel(channel = VoiceChannel) {
    const connection = joinVoiceChannel({
          channelId: channel.id,
          guildId: channel.guild.id,
          adapterCreator: createDiscordJSAdapter(channel),
      });
    try {
      await entersState(connection, VoiceConnectionStatus.Ready, 30e3);
      return connection;
      } catch (error) {
      connection.destroy();
          throw 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!');
        }
    }
});

I have this error : Screenshot of console error

This error is here in my index.js :

const { createDiscordJSAdapter } = require ('./?');

I just don't know how import this function createDiscordJSAdapter ....

I have my .env file true, (the bot is connected to my server). I have my folder music with my song name "try.mp3". And this index.js :D

If someone can help me to build this simple exemple, Thx ! Sunclies

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda