Paige
Paige
DIAdiscord.js - Imagine an app
Created by Paige on 11/12/2023 in #djs-voice
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buff
const con = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
})

const player = createAudioPlayer()
console.log(`made player`)
console.log(`buffer`, buffer)
const resource = createAudioResource(buffer)
console.log(`made resource`)

player.play(resource)
console.log(`played resource`)

con.subscribe(player)
console.log(`connection subscribed to player`)

con.on(`error`, (error) => {
console.log(error)
con.destroy()
})
const con = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
})

const player = createAudioPlayer()
console.log(`made player`)
console.log(`buffer`, buffer)
const resource = createAudioResource(buffer)
console.log(`made resource`)

player.play(resource)
console.log(`played resource`)

con.subscribe(player)
console.log(`connection subscribed to player`)

con.on(`error`, (error) => {
console.log(error)
con.destroy()
})
I am currently using this to join a voice channel and play back audio, but I am getting the error "TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (73)" As a sanity check I logged my buffer which of course was indeed a buffer, what am I doing wrong? Output:
made player
buffer <Buffer 49 44 33 04 00 00 00 00 00 22 54 53 53 45 00 00 00 0e 00 00 03 4c 61 76 66 36 30 2e 33 2e 31 30 30 00 00 00 00 00 00 00 00 00 00 00 ff fb 94 64 00 0e ... 3536250 more bytes>
made resource
played resource
connection subscribed to player
Uncaught Exception Stack:
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (73)
at new NodeError (node:internal/errors:405:5)
at _write (node:internal/streams/writable:322:13)
at Writable.write (node:internal/streams/writable:344:10)
at pumpToNode (node:internal/streams/pipeline:136:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
made player
buffer <Buffer 49 44 33 04 00 00 00 00 00 22 54 53 53 45 00 00 00 0e 00 00 03 4c 61 76 66 36 30 2e 33 2e 31 30 30 00 00 00 00 00 00 00 00 00 00 00 ff fb 94 64 00 0e ... 3536250 more bytes>
made resource
played resource
connection subscribed to player
Uncaught Exception Stack:
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (73)
at new NodeError (node:internal/errors:405:5)
at _write (node:internal/streams/writable:322:13)
at Writable.write (node:internal/streams/writable:344:10)
at pumpToNode (node:internal/streams/pipeline:136:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
8 replies