diff --git a/adapters/discord/src/message.ts b/adapters/discord/src/message.ts index 23723c6c..c030d822 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) } @@ -300,7 +301,15 @@ export class DiscordMessageEncoder extends MessageE } else if (type === 'audio') { await this.sendAsset('file', attrs, { ...this.addition, - content: this.buffer.trim(), + content: '', + attachments: [ + { + waveform: '', // base64 encoded bytearray representing a sampled waveform + id: 0, + duration_secs: attrs.duration ?? 0, + }, + ], + flags: Message.Flag.IS_VOICE_MESSAGE, }) this.buffer = '' } else if (type === 'author') { diff --git a/adapters/discord/src/types/message.ts b/adapters/discord/src/types/message.ts index 56789f7b..676bb755 100644 --- a/adapters/discord/src/types/message.ts +++ b/adapters/discord/src/types/message.ts @@ -134,6 +134,10 @@ export namespace Message { LOADING = 1 << 7, /** this message failed to mention some roles and add their members to the thread */ FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8, + /** this message will not trigger push and desktop notifications */ + SUPPRESS_NOTIFICATIONS = 1 << 12, + /** this message is a voice message */ + IS_VOICE_MESSAGE = 1 << 13, } /** https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure */