feat: voice messages

#9444 djs
This commit is contained in:
Elysia
2023-04-25 18:18:55 +07:00
parent ebf9e6f3ea
commit 30457a0e81
6 changed files with 47 additions and 7 deletions

View File

@@ -147,6 +147,28 @@ class MessageAttachment {
* @type {boolean}
*/
this.ephemeral = data.ephemeral ?? false;
if ('duration_secs' in data) {
/**
* The duration of this attachment in seconds
* <info>This will only be available if the attachment is an audio file.</info>
* @type {?number}
*/
this.duration = data.duration_secs;
} else {
this.duration ??= null;
}
if ('waveform' in data) {
/**
* The base64 encoded byte array representing a sampled waveform
* <info>This will only be available if the attachment is an audio file.</info>
* @type {?string}
*/
this.waveform = data.waveform;
} else {
this.waveform ??= null;
}
}
/**

View File

@@ -1201,6 +1201,7 @@ exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_
* * FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT
* @typedef {string} APIError
* @see {@link https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes}
* @see {@link https://gist.github.com/Dziurwa14/de2498e5ee28d2089f095aa037957cbb}
*/
exports.APIErrors = {
UNKNOWN_ACCOUNT: 10001,
@@ -1356,6 +1357,11 @@ exports.APIErrors = {
INVALID_FILE_ASSET_SIZE_RESIZE_GIF: 50138,
CANNOT_MIX_SUBSCRIPTION_AND_NON_SUBSCRIPTION_ROLES_FOR_EMOJI: 50144,
CANNOT_CONVERT_PREMIUM_EMOJI_TO_NORMAL_EMOJI: 50145,
VOICE_MESSAGES_DO_NOT_SUPPORT_ADDITIONAL_CONTENT: 50159,
VOICE_MESSAGES_MUST_HAVE_A_SINGLE_AUDIO_ATTACHMENT: 50160,
VOICE_MESSAGES_MUST_HAVE_SUPPORTING_METADATA: 50161,
VOICE_MESSAGES_CANNOT_BE_EDITED: 50162,
YOU_CANNOT_SEND_VOICE_MESSAGES_IN_THIS_CHANNEL: 50173,
TWO_FACTOR_ENABLED: 60001,
TWO_FACTOR_DISABLED: 60002,
TWO_FACTOR_REQUIRED: 60003,

View File

@@ -33,6 +33,7 @@ class MessageFlags extends BitField {}
* * `LOADING`
* * `FAILED_TO_MENTION_SOME_ROLES_IN_THREAD`
* * `SUPPRESS_NOTIFICATIONS`
* * `IS_VOICE_MESSAGE`
* @type {Object}
* @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-flags}
*/
@@ -47,6 +48,7 @@ MessageFlags.FLAGS = {
LOADING: 1 << 7,
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 1 << 8,
SUPPRESS_NOTIFICATIONS: 1 << 12,
IS_VOICE_MESSAGE: 1 << 13,
};
module.exports = MessageFlags;

View File

@@ -160,6 +160,7 @@ Permissions.FLAGS = {
MODERATE_MEMBERS: 1n << 40n,
VIEW_CREATOR_MONETIZATION_ANALYTICS: 1n << 41n,
USE_SOUNDBOARD: 1n << 42n,
SEND_VOICE_MESSAGES: 1n << 46n,
};
/**