From 3dac5b93e7568ba2fbd3bc30d229d2df80f96eed Mon Sep 17 00:00:00 2001 From: MateoDeveloper <79017590+Mateo-tem@users.noreply.github.com> Date: Fri, 21 Apr 2023 03:33:12 -0500 Subject: [PATCH] feat: add support for voice messages (#749) Co-authored-by: advaith --- deno/payloads/common.ts | 1 + deno/payloads/v10/channel.ts | 10 +++++++++- deno/payloads/v9/channel.ts | 10 +++++++++- deno/rest/common.ts | 8 +++++++- payloads/common.ts | 1 + payloads/v10/channel.ts | 10 +++++++++- payloads/v9/channel.ts | 10 +++++++++- rest/common.ts | 8 +++++++- 8 files changed, 52 insertions(+), 6 deletions(-) diff --git a/deno/payloads/common.ts b/deno/payloads/common.ts index 6b500bbe..c135423a 100644 --- a/deno/payloads/common.ts +++ b/deno/payloads/common.ts @@ -59,6 +59,7 @@ export const PermissionFlagsBits = { * @unstable This permission flag is currently not documented by Discord but has a known value which we will try to keep up to date. */ UseExternalSounds: 1n << 45n, + SendVoiceMessages: 1n << 46n, } as const; /** diff --git a/deno/payloads/v10/channel.ts b/deno/payloads/v10/channel.ts index f69939e1..134f1af7 100644 --- a/deno/payloads/v10/channel.ts +++ b/deno/payloads/v10/channel.ts @@ -807,7 +807,7 @@ export enum MessageFlags { */ SuppressNotifications = 1 << 12, /** - * @unstable This message flag is currently not documented by Discord but has a known value which we will try to keep up to date. + * This message is a voice message */ IsVoiceMessage = 1 << 13, } @@ -1321,6 +1321,14 @@ export interface APIAttachment { * Whether this attachment is ephemeral */ ephemeral?: boolean; + /** + * The duration of the audio file (currently for voice messages) + */ + duration_secs?: number; + /** + * Base64 encoded bytearray representing a sampled waveform (currently for voice messages) + */ + waveform?: string; } /** diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 99b5613b..e583dadb 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -793,7 +793,7 @@ export enum MessageFlags { */ SuppressNotifications = 1 << 12, /** - * @unstable This message flag is currently not documented by Discord but has a known value which we will try to keep up to date. + * This message is a voice message */ IsVoiceMessage = 1 << 13, } @@ -1289,6 +1289,14 @@ export interface APIAttachment { * Whether this attachment is ephemeral */ ephemeral?: boolean; + /** + * The duration of the audio file (currently for voice messages) + */ + duration_secs?: number; + /** + * Base64 encoded bytearray representing a sampled waveform (currently for voice messages) + */ + waveform?: string; } /** diff --git a/deno/rest/common.ts b/deno/rest/common.ts index 3b193855..7ba82085 100644 --- a/deno/rest/common.ts +++ b/deno/rest/common.ts @@ -232,7 +232,13 @@ export enum RESTJSONErrorCodes { CannotConvertBetweenPremiumEmojiAndNormalEmoji, UploadedFileNotFound, - CannotDeleteGuildSubscriptionIntegration = 50163, + VoiceMessagesDoNotSupportAdditionalContent = 50159, + VoiceMessagesMustHaveASingleAudioAttachment, + VoiceMessagesMustHaveSupportingMetadata, + VoiceMessagesCannotBeEdited, + CannotDeleteGuildSubscriptionIntegration, + + YouCannotSendVoiceMessagesInThisChannel = 50173, YouDoNotHavePermissionToSendThisSticker = 50600, diff --git a/payloads/common.ts b/payloads/common.ts index b84a6762..46e3fb8b 100644 --- a/payloads/common.ts +++ b/payloads/common.ts @@ -59,6 +59,7 @@ export const PermissionFlagsBits = { * @unstable This permission flag is currently not documented by Discord but has a known value which we will try to keep up to date. */ UseExternalSounds: 1n << 45n, + SendVoiceMessages: 1n << 46n, } as const; /** diff --git a/payloads/v10/channel.ts b/payloads/v10/channel.ts index 7e652602..b96ed47b 100644 --- a/payloads/v10/channel.ts +++ b/payloads/v10/channel.ts @@ -807,7 +807,7 @@ export enum MessageFlags { */ SuppressNotifications = 1 << 12, /** - * @unstable This message flag is currently not documented by Discord but has a known value which we will try to keep up to date. + * This message is a voice message */ IsVoiceMessage = 1 << 13, } @@ -1321,6 +1321,14 @@ export interface APIAttachment { * Whether this attachment is ephemeral */ ephemeral?: boolean; + /** + * The duration of the audio file (currently for voice messages) + */ + duration_secs?: number; + /** + * Base64 encoded bytearray representing a sampled waveform (currently for voice messages) + */ + waveform?: string; } /** diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 050fe371..b56db31f 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -793,7 +793,7 @@ export enum MessageFlags { */ SuppressNotifications = 1 << 12, /** - * @unstable This message flag is currently not documented by Discord but has a known value which we will try to keep up to date. + * This message is a voice message */ IsVoiceMessage = 1 << 13, } @@ -1289,6 +1289,14 @@ export interface APIAttachment { * Whether this attachment is ephemeral */ ephemeral?: boolean; + /** + * The duration of the audio file (currently for voice messages) + */ + duration_secs?: number; + /** + * Base64 encoded bytearray representing a sampled waveform (currently for voice messages) + */ + waveform?: string; } /** diff --git a/rest/common.ts b/rest/common.ts index 3b193855..7ba82085 100644 --- a/rest/common.ts +++ b/rest/common.ts @@ -232,7 +232,13 @@ export enum RESTJSONErrorCodes { CannotConvertBetweenPremiumEmojiAndNormalEmoji, UploadedFileNotFound, - CannotDeleteGuildSubscriptionIntegration = 50163, + VoiceMessagesDoNotSupportAdditionalContent = 50159, + VoiceMessagesMustHaveASingleAudioAttachment, + VoiceMessagesMustHaveSupportingMetadata, + VoiceMessagesCannotBeEdited, + CannotDeleteGuildSubscriptionIntegration, + + YouCannotSendVoiceMessagesInThisChannel = 50173, YouDoNotHavePermissionToSendThisSticker = 50600,