mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:08:27 +00:00
feat(discord): add silent support for voice messages
- Add silent flag to sendDiscordVoiceMessage - Combines VOICE_MESSAGE (8192) + SUPPRESS_NOTIFICATIONS (4096) flags - Pass silent through VoiceMessageOpts and action handlers
This commit is contained in:
@@ -258,6 +258,7 @@ export async function handleDiscordMessagingAction(
|
|||||||
const result = await sendVoiceMessageDiscord(to, mediaUrl, {
|
const result = await sendVoiceMessageDiscord(to, mediaUrl, {
|
||||||
...(accountId ? { accountId } : {}),
|
...(accountId ? { accountId } : {}),
|
||||||
replyTo,
|
replyTo,
|
||||||
|
silent,
|
||||||
});
|
});
|
||||||
return jsonResult({ ok: true, result, voiceMessage: true });
|
return jsonResult({ ok: true, result, voiceMessage: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import type { RetryRunner } from "../infra/retry-policy.js";
|
|||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
|
|
||||||
const DISCORD_VOICE_MESSAGE_FLAG = 8192;
|
const DISCORD_VOICE_MESSAGE_FLAG = 8192;
|
||||||
|
const SUPPRESS_NOTIFICATIONS_FLAG = 4096;
|
||||||
const WAVEFORM_SAMPLES = 256;
|
const WAVEFORM_SAMPLES = 256;
|
||||||
|
|
||||||
export type VoiceMessageMetadata = {
|
export type VoiceMessageMetadata = {
|
||||||
@@ -225,6 +226,7 @@ export async function sendDiscordVoiceMessage(
|
|||||||
replyTo: string | undefined,
|
replyTo: string | undefined,
|
||||||
request: RetryRunner,
|
request: RetryRunner,
|
||||||
token: string,
|
token: string,
|
||||||
|
silent?: boolean,
|
||||||
): Promise<{ id: string; channel_id: string }> {
|
): Promise<{ id: string; channel_id: string }> {
|
||||||
const filename = "voice-message.ogg";
|
const filename = "voice-message.ogg";
|
||||||
const fileSize = audioBuffer.byteLength;
|
const fileSize = audioBuffer.byteLength;
|
||||||
@@ -278,6 +280,9 @@ export async function sendDiscordVoiceMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Send the message with voice message flag and metadata
|
// Step 3: Send the message with voice message flag and metadata
|
||||||
|
const flags = silent
|
||||||
|
? DISCORD_VOICE_MESSAGE_FLAG | SUPPRESS_NOTIFICATIONS_FLAG
|
||||||
|
: DISCORD_VOICE_MESSAGE_FLAG;
|
||||||
const messagePayload: {
|
const messagePayload: {
|
||||||
flags: number;
|
flags: number;
|
||||||
attachments: Array<{
|
attachments: Array<{
|
||||||
@@ -289,7 +294,7 @@ export async function sendDiscordVoiceMessage(
|
|||||||
}>;
|
}>;
|
||||||
message_reference?: { message_id: string; fail_if_not_exists: boolean };
|
message_reference?: { message_id: string; fail_if_not_exists: boolean };
|
||||||
} = {
|
} = {
|
||||||
flags: DISCORD_VOICE_MESSAGE_FLAG,
|
flags,
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
id: "0",
|
id: "0",
|
||||||
|
|||||||
Reference in New Issue
Block a user