aiko-chan-ai/discord.js-selfbot-v13

voice messages failing

Closed this issue · 2 comments

Which package has the bugs?

The core library

Issue description

i got this error when i sent a voice message:

0|index  | DiscordAPIError: Invalid Form Body
0|index  | attachments[0]: Attachment metadata is invalid
0|index  |     at RequestHandler.execute (/Users/____/catbot/node_modules/.pnpm/discord.js-selfbot-v13@3.1.4/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:415:13)
0|index  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|index  |     at async RequestHandler.push (/Users/____/catbot/node_modules/.pnpm/discord.js-selfbot-v13@3.1.4/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:63:14)
0|index  |     at async GroupDMChannel.send (/Users/____/catbot/node_modules/.pnpm/discord.js-selfbot-v13@3.1.4/node_modules/discord.js-selfbot-v13/src/structures/interfaces/TextBasedChannel.js:184:15) {
0|index  |   method: 'post',
0|index  |   path: '/channels/###############/messages',
0|index  |   code: 50035,
0|index  |   httpStatus: 400,
0|index  |   requestData: {
0|index  |     json: {
0|index  |       activity: undefined,
0|index  |       content: undefined,
0|index  |       tts: false,
0|index  |       nonce: undefined,
0|index  |       embeds: undefined,
0|index  |       components: undefined,
0|index  |       username: undefined,
0|index  |       avatar_url: undefined,
0|index  |       allowed_mentions: undefined,
0|index  |       flags: 8192,
0|index  |       message_reference: undefined,
0|index  |       attachments: [Array],
0|index  |       sticker_ids: undefined,
0|index  |       thread_name: undefined
0|index  |     },
0|index  |     files: [],
0|index  |     headers: undefined
0|index  |   },
0|index  |   retries: 0,
0|index  |   captcha: null
0|index  | }

i have removed my name and server id from the logs

Code sample

const attachment = new MessageAttachment('./text_to_speech.ogg', 'text_to_speech.ogg', {
    waveform: '=',
    duration_secs: 1,
});
    
message.channel.send({
    files: [attachment],
    flags: 'IS_VOICE_MESSAGE',
});

Package version

3.1.4

Node.js version

v22.2.0

Operating system

macOS

Priority this issue should have

Low (slightly annoying)

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

the file sent was generated by the built-in "say" command and converted to an ogg file via ffmpeg

ffmpeg command:

ffmpeg -i ./text_to_speech.aiff -y -ar 48000 -ac 2 -b:a 192k ./text_to_speech.ogg

i have verified that the output file is there and not corrupted
in the past the upload sometimes worked, now it never does

I managed to fix a similar issue by changing the waveform.

const attachment = new MessageAttachment(
    'C:\\path\\to\\file\\voice-message.ogg',
    'voice-message.ogg',
    {
        waveform: 'AAAAAAAAAAAAAAAAAA==',
        duration_secs: 9999,
    }
);

msg.channel.send({ files: [attachment], flags: "IS_VOICE_MESSAGE" });

I assume something in the api changed.

updated code (using waveform AAAAAAAAAAAA)