Skip to content

Commit

Permalink
feat: send voice message
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme committed Apr 18, 2024
1 parent 8f16bf5 commit d92d6ee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion adapters/discord/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export class DiscordMessageEncoder<C extends Context = Context> 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)
}
Expand Down Expand Up @@ -301,6 +302,14 @@ export class DiscordMessageEncoder<C extends Context = Context> 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,
}

Check failure on line 310 in adapters/discord/src/message.ts

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
],
flags: 8192,
})
this.buffer = ''
} else if (type === 'author') {
Expand Down

0 comments on commit d92d6ee

Please sign in to comment.