From d92d6ee6bfdb09e59f76ecb6a471696bcca786e3 Mon Sep 17 00:00:00 2001 From: idanran <96647698+idanran@users.noreply.github.com> Date: Thu, 18 Apr 2024 07:54:06 +0000 Subject: [PATCH] feat: send voice message --- adapters/discord/src/message.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/adapters/discord/src/message.ts b/adapters/discord/src/message.ts index 23723c6c..df43de15 100644 --- a/adapters/discord/src/message.ts +++ b/adapters/discord/src/message.ts @@ -88,7 +88,8 @@ export class DiscordMessageEncoder extends MessageE const { filename, data, mime } = await this.bot.ctx.http.file(attrs.src || attrs.url, attrs) const form = new FormData() const value = new Blob([data], { type: mime }) - form.append('file', value, attrs.file || filename) + // https://discord.com/developers/docs/reference#uploading-files + form.append('files[0]', value, attrs.file || filename) form.append('payload_json', JSON.stringify(payload)) return this.post(form) } @@ -301,6 +302,14 @@ export class DiscordMessageEncoder extends MessageE await this.sendAsset('file', attrs, { ...this.addition, content: this.buffer.trim(), + attachments: [ + { + waveform: '', // base64 encoded bytearray representing a sampled waveform + id: '0', + duration_secs: attrs.duration ?? 0, + } + ], + flags: 8192, }) this.buffer = '' } else if (type === 'author') {