(perdón por mi inglés) Solo quiero hacer un mensaje de reacción simple, conexión a voz donde el usuario use una palabra como "ejemplo" en este "es un ejemplo", y reproduzca una canción.mp3, después de que el bot se desconecte cuando él terminar esta cancion.mp3.
Este es mi 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!'); } } });Tengo este error: captura de pantalla del error de la consola
Este error está aquí en mi index.js:
const { createDiscordJSAdapter } = require ('./?');Simplemente no sé cómo importar esta función createDiscordJSAdapter ...
Tengo mi archivo .env verdadero (el bot está conectado a mi servidor). Tengo mi carpeta de música con el nombre de mi canción "try.mp3". Y este index.js :D
Si alguien puede ayudarme a construir este ejemplo simple, ¡Gracias! soles