Skip to content

Commit

Permalink
feat: voice message support
Browse files Browse the repository at this point in the history
  • Loading branch information
TTtie committed Apr 15, 2023
1 parent 4284002 commit 2ad80d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
8 changes: 6 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,7 @@ declare namespace Dysnomia {
LOADING: 128;
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 256;
SUPPRESS_NOTIFICATIONS: 4096;
IS_VOICE_MESSAGE: 8192;
};
MessageTypes: {
DEFAULT: 0;
Expand Down Expand Up @@ -2190,10 +2191,11 @@ declare namespace Dysnomia {
moderateMembers: 1099511627776n;
viewCreatorMonetizationAnalytics: 2199023255552n;
useSoundboard: 4398046511104n;
sendVoiceMessages: 70368744177664n;
allGuild: 3309205717182n;
allText: 535529258065n;
allText: 70904273435729n;
allVoice: 4952431789841n;
all: 8796093022207n;
all: 79164837199871n;
};
PremiumTiers: {
NONE: 0;
Expand Down Expand Up @@ -2370,13 +2372,15 @@ declare namespace Dysnomia {
export class Attachment extends Base {
contentType?: string;
description?: string;
durationSecs?: number;
ephemeral?: boolean;
filename: string;
height?: number;
id: string;
proxyURL: string;
size: number;
url: string;
waveform?: Buffer;
width?: number;
constructor(data: BaseData);
}
Expand Down
9 changes: 6 additions & 3 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ module.exports.MessageFlags = {
EPHEMERAL: 1 << 6,
LOADING: 1 << 7,
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 1 << 8,
SUPPRESS_NOTIFICATIONS: 1 << 12
SUPPRESS_NOTIFICATIONS: 1 << 12,
IS_VOICE_MESSAGE: 1 << 13
};

module.exports.MessageTypes = {
Expand Down Expand Up @@ -495,7 +496,8 @@ const Permissions = {
startEmbeddedActivities: 1n << 39n,
moderateMembers: 1n << 40n,
viewCreatorMonetizationAnalytics: 1n << 41n,
useSoundboard: 1n << 42n
useSoundboard: 1n << 42n,
sendVoiceMessages: 1n << 46n
};
Permissions.allGuild = Permissions.kickMembers
| Permissions.banMembers
Expand Down Expand Up @@ -531,7 +533,8 @@ Permissions.allText = Permissions.createInstantInvite
| Permissions.createPublicThreads
| Permissions.createPrivateThreads
| Permissions.useExternalStickers
| Permissions.sendMessagesInThreads;
| Permissions.sendMessagesInThreads
| Permissions.sendVoiceMessages;
Permissions.allVoice = Permissions.createInstantInvite
| Permissions.manageChannels
| Permissions.voicePrioritySpeaker
Expand Down
8 changes: 8 additions & 0 deletions lib/structures/Attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const Base = require("./Base");
* Represents an attachment
* @prop {String?} contentType The content type of the attachment
* @prop {String?} description The description of the attachment
* @prop {Number?} durationSecs The duration of the audio file (voice messages only)
* @prop {Boolean?} ephemeral Whether the attachment is ephemeral
* @prop {String} filename The filename of the attachment
* @prop {Number?} height The height of the attachment
* @prop {String} id The attachment ID
* @prop {String} proxyURL The proxy URL of the attachment
* @prop {Number} size The size of the attachment
* @prop {String} url The URL of the attachment
* @prop {Buffer?} waveform A buffer representing the sampled waveform of the audio file (voice messages only)
* @prop {Number?} width The width of the attachment
*/
class Attachment extends Base {
Expand All @@ -23,6 +25,10 @@ class Attachment extends Base {
this.size = data.size;
this.url = data.url;
this.proxyURL = data.proxy_url;
this.durationSecs = data.duration_secs;
if(data.waveform !== undefined) {
this.waveform = Buffer.from(data.waveform, "base64");
}
this.update(data);
}

Expand Down Expand Up @@ -55,6 +61,8 @@ class Attachment extends Base {
"height",
"width",
"ephemeral",
"durationSecs",
"waveform",
...props
]);
}
Expand Down

0 comments on commit 2ad80d0

Please sign in to comment.