Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix MessagePayload.js to send voice message #10298

Open
SammyKunimatsu opened this issue May 24, 2024 · 0 comments · May be fixed by #10462
Open

fix MessagePayload.js to send voice message #10298

SammyKunimatsu opened this issue May 24, 2024 · 0 comments · May be fixed by #10462

Comments

@SammyKunimatsu
Copy link

SammyKunimatsu commented May 24, 2024

Which package is this bug report for?

discord.js

Issue description

  1. const attachments = this.options.files?.map((file, index) => ({
    id: index.toString(),
    description: file.description,
    }));

  2. Change this selection to:

const attachments = this.options.files?.map((file, index) => ({
      id: index.toString(),
      description: file.description,
      duration_secs: file.duration_secs,
      waveform: file.waveform
    }));

Code sample

import getAudio from 'get-audio-duration';

await interaction.channel.send({ files: [
        {
          attachment: "/local/audio/audio.mp3",
          name: 'audio.mp3',
          contentType: 'audio/mp3',
          waveform: new Buffer(new Uint8Array([1,2,3])).toString("base64"),
          //@ts-ignore
          duration_secs: await getAudio("/local/audio/audio.mp3")
        }
      ],
      flags: new MessageFlagsBitField([MessageFlags.IsVoiceMessage]).toJSON()
     });

Versions

  • discord.js v14.15.2
  • Node.JS v22.1.0
  • Typescript v4.7.4
  • Windows 11

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

Message

Which gateway intents are you subscribing to?

MessageContent

I have tested this issue on a development release

No response

DwifteJB added a commit to DwifteJB/discord.js that referenced this issue May 31, 2024
@almeidx almeidx linked a pull request Aug 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants