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

@ -61,7 +61,7 @@
"@types/ws": "^8.5.4",
"axios": "1.1",
"chalk": "^4.1.2",
"discord-api-types": "^0.37.37",
"discord-api-types": "^0.37.40",
"form-data": "^4.0.0",
"json-bigint": "^1.0.0",
"lodash.permutations": "^1.0.0",
@ -82,10 +82,10 @@
"@commitlint/config-angular": "^16.0.0",
"@discordjs/docgen": "^0.11.1",
"@favware/npm-deprecate": "^1.0.7",
"@types/node": "^18.15.11",
"@types/node": "^18.16.0",
"conventional-changelog-cli": "^2.2.2",
"dtslint": "^4.2.1",
"eslint": "^8.36.0",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
@ -93,8 +93,8 @@
"is-ci": "^3.0.1",
"jest": "^28.1.3",
"lint-staged": "^12.1.4",
"prettier": "^2.8.7",
"tsd": "^0.25.0",
"prettier": "^2.8.8",
"tsd": "^0.28.1",
"tslint": "^6.1.3",
"typescript": "^4.9.5"
}

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,
};
/**

13
typings/index.d.ts vendored
View File

@ -2157,6 +2157,7 @@ export class MessageAttachment {
public attachment: BufferResolvable | Stream;
public contentType: string | null;
public description: string | null;
public duration: number | null;
public ephemeral: boolean;
public height: number | null;
public id: Snowflake;
@ -2165,6 +2166,7 @@ export class MessageAttachment {
public size: number;
public readonly spoiler: boolean;
public url: string;
public waveform: string | null;
public width: number | null;
public setDescription(description: string): this;
public setFile(attachment: BufferResolvable | Stream, name?: string): this;
@ -4671,6 +4673,11 @@ export interface APIErrors {
INSUFFICIENT_BOOSTS: 50101;
INVALID_JSON: 50109;
CANNOT_MIX_SUBSCRIPTION_AND_NON_SUBSCRIPTION_ROLES_FOR_EMOJI: 50144;
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;
CANNOT_CONVERT_PREMIUM_EMOJI_TO_NORMAL_EMOJI: 50145;
TWO_FACTOR_REQUIRED: 60003;
INVALID_TWO_FACTOR_CODE: 60008;
@ -6807,7 +6814,8 @@ export type MessageFlagsString =
| 'EPHEMERAL'
| 'LOADING'
| 'FAILED_TO_MENTION_SOME_ROLES_IN_THREAD'
| 'SUPPRESS_NOTIFICATIONS';
| 'SUPPRESS_NOTIFICATIONS'
| 'IS_VOICE_MESSAGE';
export interface MessageInteraction {
id: Snowflake;
@ -7023,7 +7031,8 @@ export type PermissionString =
| 'MODERATE_MEMBERS'
| 'MANAGE_EVENTS'
| 'VIEW_CREATOR_MONETIZATION_ANALYTICS'
| 'USE_SOUNDBOARD';
| 'USE_SOUNDBOARD'
| 'SEND_VOICE_MESSAGES';
export type RecursiveArray<T> = ReadonlyArray<T | RecursiveArray<T>>;