discord.js 15.0.0-pr-11006.1765450794-e636950b2 → 15.0.0-pr-11005.1765454364-f3f6d34e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -14
- package/src/client/Client.js +10 -3
- package/src/client/websocket/handlers/READY.js +0 -4
- package/src/errors/DJSError.js +3 -7
- package/src/errors/ErrorCodes.js +2 -2
- package/src/errors/Messages.js +2 -2
- package/src/index.js +1 -0
- package/src/managers/ChannelManager.js +7 -10
- package/src/managers/GuildEmojiManager.js +2 -2
- package/src/managers/MessageManager.js +9 -16
- package/src/structures/AttachmentBuilder.js +185 -0
- package/src/structures/Embed.js +1 -1
- package/src/structures/Guild.js +1 -11
- package/src/structures/GuildInvite.js +1 -1
- package/src/structures/Message.js +9 -9
- package/src/structures/MessagePayload.js +4 -7
- package/src/structures/interfaces/TextBasedChannel.js +2 -2
- package/src/util/APITypes.js +0 -10
- package/typings/index.d.mts +113 -107
- package/typings/index.d.ts +113 -107
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "discord.js",
|
|
4
|
-
"version": "15.0.0-pr-
|
|
4
|
+
"version": "15.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
5
5
|
"description": "A powerful library for interacting with the Discord API",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./typings/index.d.ts",
|
|
@@ -55,33 +55,35 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@sapphire/snowflake": "3.5.5",
|
|
57
57
|
"@vladfrangu/async_event_emitter": "^2.4.7",
|
|
58
|
-
"discord-api-types": "^0.38.
|
|
58
|
+
"discord-api-types": "^0.38.31",
|
|
59
59
|
"fast-deep-equal": "3.1.3",
|
|
60
60
|
"lodash.snakecase": "4.1.1",
|
|
61
61
|
"magic-bytes.js": "^1.12.1",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
63
|
"undici": "7.16.0",
|
|
64
|
-
"@discordjs/
|
|
65
|
-
"@discordjs/
|
|
66
|
-
"@discordjs/collection": "3.0.0-pr-
|
|
67
|
-
"@discordjs/rest": "3.0.0-pr-
|
|
68
|
-
"@discordjs/util": "2.0.0-pr-
|
|
69
|
-
"@discordjs/ws": "3.0.0-pr-
|
|
64
|
+
"@discordjs/formatters": "1.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
65
|
+
"@discordjs/builders": "2.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
66
|
+
"@discordjs/collection": "3.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
67
|
+
"@discordjs/rest": "3.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
68
|
+
"@discordjs/util": "2.0.0-pr-11005.1765454364-f3f6d34e7",
|
|
69
|
+
"@discordjs/ws": "3.0.0-pr-11005.1765454364-f3f6d34e7"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@favware/cliff-jumper": "^
|
|
73
|
-
"@types/node": "^22.
|
|
72
|
+
"@favware/cliff-jumper": "^4.1.0",
|
|
73
|
+
"@types/node": "^22.18.13",
|
|
74
74
|
"cross-env": "^10.1.0",
|
|
75
|
-
"eslint": "^9.
|
|
75
|
+
"eslint": "^9.38.0",
|
|
76
76
|
"eslint-config-neon": "^0.2.9",
|
|
77
77
|
"eslint-formatter-compact": "^9.0.1",
|
|
78
78
|
"eslint-formatter-pretty": "^7.0.0",
|
|
79
|
-
"
|
|
79
|
+
"eslint-plugin-import": "^2.32.0",
|
|
80
|
+
"eslint-plugin-jsdoc": "^54.7.0",
|
|
81
|
+
"prettier": "^3.6.2",
|
|
80
82
|
"tsd": "^0.33.0",
|
|
81
|
-
"turbo": "^2.
|
|
83
|
+
"turbo": "^2.5.8",
|
|
82
84
|
"typescript": "~5.9.3",
|
|
83
|
-
"@discordjs/docgen": "0.12.1",
|
|
84
85
|
"@discordjs/api-extractor": "7.52.7",
|
|
86
|
+
"@discordjs/docgen": "0.12.1",
|
|
85
87
|
"@discordjs/scripts": "0.1.0"
|
|
86
88
|
},
|
|
87
89
|
"engines": {
|
package/src/client/Client.js
CHANGED
|
@@ -389,6 +389,15 @@ class Client extends AsyncEventEmitter {
|
|
|
389
389
|
);
|
|
390
390
|
this.ws.on(WebSocketShardEvents.Dispatch, this._handlePacket.bind(this));
|
|
391
391
|
|
|
392
|
+
this.ws.on(WebSocketShardEvents.Ready, async data => {
|
|
393
|
+
for (const guild of data.guilds) {
|
|
394
|
+
this.expectedGuilds.add(guild.id);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this.status = Status.WaitingForGuilds;
|
|
398
|
+
await this._checkReady();
|
|
399
|
+
});
|
|
400
|
+
|
|
392
401
|
this.ws.on(WebSocketShardEvents.HeartbeatComplete, ({ heartbeatAt, latency }, shardId) => {
|
|
393
402
|
this.emit(Events.Debug, `[WS => Shard ${shardId}] Heartbeat acknowledged, latency of ${latency}ms.`);
|
|
394
403
|
this.lastPingTimestamps.set(shardId, heartbeatAt);
|
|
@@ -418,9 +427,7 @@ class Client extends AsyncEventEmitter {
|
|
|
418
427
|
PacketHandlers[packet.t](this, packet, shardId);
|
|
419
428
|
}
|
|
420
429
|
|
|
421
|
-
if (
|
|
422
|
-
await this._checkReady();
|
|
423
|
-
} else if (this.status === Status.WaitingForGuilds && WaitingForGuildEvents.includes(packet.t)) {
|
|
430
|
+
if (this.status === Status.WaitingForGuilds && WaitingForGuildEvents.includes(packet.t)) {
|
|
424
431
|
this.expectedGuilds.delete(packet.d.id);
|
|
425
432
|
await this._checkReady();
|
|
426
433
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { ClientApplication } = require('../../../structures/ClientApplication.js');
|
|
4
|
-
const { Status } = require('../../../util/Status.js');
|
|
5
4
|
|
|
6
5
|
let ClientUser;
|
|
7
6
|
|
|
@@ -15,7 +14,6 @@ module.exports = (client, { d: data }, shardId) => {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
for (const guild of data.guilds) {
|
|
18
|
-
client.expectedGuilds.add(guild.id);
|
|
19
17
|
guild.shardId = shardId;
|
|
20
18
|
client.guilds._add(guild);
|
|
21
19
|
}
|
|
@@ -25,6 +23,4 @@ module.exports = (client, { d: data }, shardId) => {
|
|
|
25
23
|
} else {
|
|
26
24
|
client.application = new ClientApplication(client, data.application);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
client.status = Status.WaitingForGuilds;
|
|
30
26
|
};
|
package/src/errors/DJSError.js
CHANGED
|
@@ -12,19 +12,15 @@ const { Messages } = require('./Messages.js');
|
|
|
12
12
|
* @ignore
|
|
13
13
|
*/
|
|
14
14
|
function makeDiscordjsError(Base) {
|
|
15
|
-
return class extends Base {
|
|
16
|
-
static {
|
|
17
|
-
Object.defineProperty(this, 'name', { value: `Discordjs${Base.name}` });
|
|
18
|
-
}
|
|
19
|
-
|
|
15
|
+
return class DiscordjsError extends Base {
|
|
20
16
|
constructor(code, ...args) {
|
|
21
17
|
super(message(code, args));
|
|
22
18
|
this.code = code;
|
|
23
|
-
Error.captureStackTrace(this,
|
|
19
|
+
Error.captureStackTrace?.(this, DiscordjsError);
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
get name() {
|
|
27
|
-
return `${
|
|
23
|
+
return `${super.name} [${this.code}]`;
|
|
28
24
|
}
|
|
29
25
|
};
|
|
30
26
|
}
|
package/src/errors/ErrorCodes.js
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
*
|
|
84
84
|
* @property {'EmojiType'} EmojiType
|
|
85
85
|
* @property {'EmojiManaged'} EmojiManaged
|
|
86
|
-
* @property {'
|
|
86
|
+
* @property {'MissingManageGuildExpressionsPermission'} MissingManageGuildExpressionsPermission
|
|
87
87
|
*
|
|
88
88
|
* @property {'NotGuildSoundboardSound'} NotGuildSoundboardSound
|
|
89
89
|
* @property {'NotGuildSticker'} NotGuildSticker
|
|
@@ -217,7 +217,7 @@ const keys = [
|
|
|
217
217
|
|
|
218
218
|
'EmojiType',
|
|
219
219
|
'EmojiManaged',
|
|
220
|
-
'
|
|
220
|
+
'MissingManageGuildExpressionsPermission',
|
|
221
221
|
|
|
222
222
|
'NotGuildSoundboardSound',
|
|
223
223
|
'NotGuildSticker',
|
package/src/errors/Messages.js
CHANGED
|
@@ -88,8 +88,8 @@ const Messages = {
|
|
|
88
88
|
|
|
89
89
|
[ErrorCodes.EmojiType]: 'Emoji must be a string or GuildEmoji/ReactionEmoji',
|
|
90
90
|
[ErrorCodes.EmojiManaged]: 'Emoji is managed and has no Author.',
|
|
91
|
-
[ErrorCodes.
|
|
92
|
-
`Client must have
|
|
91
|
+
[ErrorCodes.MissingManageGuildExpressionsPermission]: guild =>
|
|
92
|
+
`Client must have Manage Guild Expressions permission in guild ${guild} to see emoji authors.`,
|
|
93
93
|
|
|
94
94
|
[ErrorCodes.NotGuildSoundboardSound]: action =>
|
|
95
95
|
`Soundboard sound is a default (non-guild) soundboard sound and can't be ${action}.`,
|
package/src/index.js
CHANGED
|
@@ -111,6 +111,7 @@ exports.ApplicationEmoji = require('./structures/ApplicationEmoji.js').Applicati
|
|
|
111
111
|
exports.ApplicationRoleConnectionMetadata =
|
|
112
112
|
require('./structures/ApplicationRoleConnectionMetadata.js').ApplicationRoleConnectionMetadata;
|
|
113
113
|
exports.Attachment = require('./structures/Attachment.js').Attachment;
|
|
114
|
+
exports.AttachmentBuilder = require('./structures/AttachmentBuilder.js').AttachmentBuilder;
|
|
114
115
|
exports.AutocompleteInteraction = require('./structures/AutocompleteInteraction.js').AutocompleteInteraction;
|
|
115
116
|
exports.AutoModerationActionExecution =
|
|
116
117
|
require('./structures/AutoModerationActionExecution.js').AutoModerationActionExecution;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const process = require('node:process');
|
|
4
|
-
const { lazy
|
|
4
|
+
const { lazy } = require('@discordjs/util');
|
|
5
5
|
const { Routes } = require('discord-api-types/v10');
|
|
6
6
|
const { BaseChannel } = require('../structures/BaseChannel.js');
|
|
7
7
|
const { MessagePayload } = require('../structures/MessagePayload.js');
|
|
@@ -147,7 +147,7 @@ class ChannelManager extends CachedManager {
|
|
|
147
147
|
* Creates a message in a channel.
|
|
148
148
|
*
|
|
149
149
|
* @param {TextChannelResolvable} channel The channel to send the message to
|
|
150
|
-
* @param {string|MessagePayload|MessageCreateOptions
|
|
150
|
+
* @param {string|MessagePayload|MessageCreateOptions} options The options to provide
|
|
151
151
|
* @returns {Promise<Message>}
|
|
152
152
|
* @example
|
|
153
153
|
* // Send a basic message
|
|
@@ -174,21 +174,18 @@ class ChannelManager extends CachedManager {
|
|
|
174
174
|
* .catch(console.error);
|
|
175
175
|
*/
|
|
176
176
|
async createMessage(channel, options) {
|
|
177
|
-
let
|
|
177
|
+
let messagePayload;
|
|
178
178
|
|
|
179
179
|
if (options instanceof MessagePayload) {
|
|
180
|
-
|
|
181
|
-
} else if (isFileBodyEncodable(options)) {
|
|
182
|
-
payload = options.toFileBody();
|
|
183
|
-
} else if (isJSONEncodable(options)) {
|
|
184
|
-
payload = { body: options.toJSON() };
|
|
180
|
+
messagePayload = options.resolveBody();
|
|
185
181
|
} else {
|
|
186
|
-
|
|
182
|
+
messagePayload = MessagePayload.create(this, options).resolveBody();
|
|
187
183
|
}
|
|
188
184
|
|
|
189
185
|
const resolvedChannelId = this.resolveId(channel);
|
|
190
186
|
const resolvedChannel = this.resolve(channel);
|
|
191
|
-
const
|
|
187
|
+
const { body, files } = await messagePayload.resolveFiles();
|
|
188
|
+
const data = await this.client.rest.post(Routes.channelMessages(resolvedChannelId), { body, files });
|
|
192
189
|
|
|
193
190
|
return resolvedChannel?.messages._add(data) ?? new (getMessage())(this.client, data);
|
|
194
191
|
}
|
|
@@ -251,8 +251,8 @@ class GuildEmojiManager extends CachedManager {
|
|
|
251
251
|
|
|
252
252
|
const { me } = this.guild.members;
|
|
253
253
|
if (!me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
|
|
254
|
-
if (!me.permissions.
|
|
255
|
-
throw new DiscordjsError(ErrorCodes.
|
|
254
|
+
if (!me.permissions.has(PermissionFlagsBits.ManageGuildExpressions)) {
|
|
255
|
+
throw new DiscordjsError(ErrorCodes.MissingManageGuildExpressionsPermission, this.guild);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
const data = await this.client.rest.get(Routes.guildEmoji(this.guild.id, resolvedEmoji.id));
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { makeURLSearchParams } = require('@discordjs/rest');
|
|
5
|
-
const { isFileBodyEncodable, isJSONEncodable } = require('@discordjs/util');
|
|
6
5
|
const { Routes } = require('discord-api-types/v10');
|
|
7
6
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
|
|
8
7
|
const { Message } = require('../structures/Message.js');
|
|
@@ -224,27 +223,21 @@ class MessageManager extends CachedManager {
|
|
|
224
223
|
* Edits a message, even if it's not cached.
|
|
225
224
|
*
|
|
226
225
|
* @param {MessageResolvable} message The message to edit
|
|
227
|
-
* @param {string|MessageEditOptions|MessagePayload
|
|
226
|
+
* @param {string|MessageEditOptions|MessagePayload} options The options to edit the message
|
|
228
227
|
* @returns {Promise<Message>}
|
|
229
228
|
*/
|
|
230
229
|
async edit(message, options) {
|
|
231
230
|
const messageId = this.resolveId(message);
|
|
232
231
|
if (!messageId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
|
|
233
232
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
payload = await MessagePayload.create(message instanceof Message ? message : this, options)
|
|
243
|
-
.resolveBody()
|
|
244
|
-
.resolveFiles();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const data = await this.client.rest.patch(Routes.channelMessage(this.channel.id, messageId), payload);
|
|
233
|
+
const { body, files } = await (
|
|
234
|
+
options instanceof MessagePayload
|
|
235
|
+
? options
|
|
236
|
+
: MessagePayload.create(message instanceof Message ? message : this, options)
|
|
237
|
+
)
|
|
238
|
+
.resolveBody()
|
|
239
|
+
.resolveFiles();
|
|
240
|
+
const data = await this.client.rest.patch(Routes.channelMessage(this.channel.id, messageId), { body, files });
|
|
248
241
|
|
|
249
242
|
const existing = this.cache.get(messageId);
|
|
250
243
|
if (existing) {
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { basename, flatten } = require('../util/Util.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an attachment builder
|
|
7
|
+
*/
|
|
8
|
+
class AttachmentBuilder {
|
|
9
|
+
/**
|
|
10
|
+
* @param {BufferResolvable|Stream} attachment The file
|
|
11
|
+
* @param {AttachmentData} [data] Extra data
|
|
12
|
+
*/
|
|
13
|
+
constructor(attachment, data = {}) {
|
|
14
|
+
/**
|
|
15
|
+
* The file associated with this attachment.
|
|
16
|
+
*
|
|
17
|
+
* @type {BufferResolvable|Stream}
|
|
18
|
+
*/
|
|
19
|
+
this.attachment = attachment;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The name of this attachment
|
|
23
|
+
*
|
|
24
|
+
* @type {?string}
|
|
25
|
+
*/
|
|
26
|
+
this.name = data.name;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The description of the attachment
|
|
30
|
+
*
|
|
31
|
+
* @type {?string}
|
|
32
|
+
*/
|
|
33
|
+
this.description = data.description;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The title of the attachment
|
|
37
|
+
*
|
|
38
|
+
* @type {?string}
|
|
39
|
+
*/
|
|
40
|
+
this.title = data.title;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The base64 encoded byte array representing a sampled waveform
|
|
44
|
+
* <info>This is only for voice message attachments.</info>
|
|
45
|
+
*
|
|
46
|
+
* @type {?string}
|
|
47
|
+
*/
|
|
48
|
+
this.waveform = data.waveform;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The duration of the attachment in seconds
|
|
52
|
+
* <info>This is only for voice message attachments.</info>
|
|
53
|
+
*
|
|
54
|
+
* @type {?number}
|
|
55
|
+
*/
|
|
56
|
+
this.duration = data.duration;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Sets the description of this attachment.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} description The description of the file
|
|
63
|
+
* @returns {AttachmentBuilder} This attachment
|
|
64
|
+
*/
|
|
65
|
+
setDescription(description) {
|
|
66
|
+
this.description = description;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the file of this attachment.
|
|
72
|
+
*
|
|
73
|
+
* @param {BufferResolvable|Stream} attachment The file
|
|
74
|
+
* @returns {AttachmentBuilder} This attachment
|
|
75
|
+
*/
|
|
76
|
+
setFile(attachment) {
|
|
77
|
+
this.attachment = attachment;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Sets the name of this attachment.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} name The name of the file
|
|
85
|
+
* @returns {AttachmentBuilder} This attachment
|
|
86
|
+
*/
|
|
87
|
+
setName(name) {
|
|
88
|
+
this.name = name;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Sets the title of this attachment.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} title The title of the file
|
|
96
|
+
* @returns {AttachmentBuilder} This attachment
|
|
97
|
+
*/
|
|
98
|
+
setTitle(title) {
|
|
99
|
+
this.title = title;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Sets the waveform of this attachment.
|
|
105
|
+
* <info>This is only for voice message attachments.</info>
|
|
106
|
+
*
|
|
107
|
+
* @param {string} waveform The base64 encoded byte array representing a sampled waveform
|
|
108
|
+
* @returns {AttachmentBuilder} This attachment
|
|
109
|
+
*/
|
|
110
|
+
setWaveform(waveform) {
|
|
111
|
+
this.waveform = waveform;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Sets the duration of this attachment.
|
|
117
|
+
* <info>This is only for voice message attachments.</info>
|
|
118
|
+
*
|
|
119
|
+
* @param {number} duration The duration of the attachment in seconds
|
|
120
|
+
* @returns {AttachmentBuilder} This attachment
|
|
121
|
+
*/
|
|
122
|
+
setDuration(duration) {
|
|
123
|
+
this.duration = duration;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sets whether this attachment is a spoiler
|
|
129
|
+
*
|
|
130
|
+
* @param {boolean} [spoiler=true] Whether the attachment should be marked as a spoiler
|
|
131
|
+
* @returns {AttachmentBuilder} This attachment
|
|
132
|
+
*/
|
|
133
|
+
setSpoiler(spoiler = true) {
|
|
134
|
+
if (spoiler === this.spoiler) return this;
|
|
135
|
+
|
|
136
|
+
if (!spoiler) {
|
|
137
|
+
while (this.spoiler) {
|
|
138
|
+
this.name = this.name.slice('SPOILER_'.length);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
this.name = `SPOILER_${this.name}`;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether or not this attachment has been marked as a spoiler
|
|
150
|
+
*
|
|
151
|
+
* @type {boolean}
|
|
152
|
+
* @readonly
|
|
153
|
+
*/
|
|
154
|
+
get spoiler() {
|
|
155
|
+
return basename(this.name).startsWith('SPOILER_');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
toJSON() {
|
|
159
|
+
return flatten(this);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Makes a new builder instance from a preexisting attachment structure.
|
|
164
|
+
*
|
|
165
|
+
* @param {AttachmentBuilder|Attachment|AttachmentPayload} other The builder to construct a new instance from
|
|
166
|
+
* @returns {AttachmentBuilder}
|
|
167
|
+
*/
|
|
168
|
+
static from(other) {
|
|
169
|
+
return new AttachmentBuilder(other.attachment, {
|
|
170
|
+
name: other.name,
|
|
171
|
+
description: other.description,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
exports.AttachmentBuilder = AttachmentBuilder;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @typedef {Object} AttachmentData
|
|
180
|
+
* @property {string} [name] The name of the attachment
|
|
181
|
+
* @property {string} [description] The description of the attachment
|
|
182
|
+
* @property {string} [title] The title of the attachment
|
|
183
|
+
* @property {string} [waveform] The base64 encoded byte array representing a sampled waveform (for voice message attachments)
|
|
184
|
+
* @property {number} [duration] The duration of the attachment in seconds (for voice message attachments)
|
|
185
|
+
*/
|
package/src/structures/Embed.js
CHANGED
package/src/structures/Guild.js
CHANGED
|
@@ -641,7 +641,7 @@ class Guild extends AnonymousGuild {
|
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
/**
|
|
644
|
-
* The maximum bitrate available for
|
|
644
|
+
* The maximum bitrate available for this guild
|
|
645
645
|
*
|
|
646
646
|
* @type {number}
|
|
647
647
|
* @readonly
|
|
@@ -663,16 +663,6 @@ class Guild extends AnonymousGuild {
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
|
|
666
|
-
/**
|
|
667
|
-
* The maximum bitrate available for a stage channel in this guild
|
|
668
|
-
*
|
|
669
|
-
* @type {number}
|
|
670
|
-
* @readonly
|
|
671
|
-
*/
|
|
672
|
-
get maximumStageBitrate() {
|
|
673
|
-
return 64_000;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
666
|
/**
|
|
677
667
|
* Fetches a collection of integrations to this guild.
|
|
678
668
|
* Resolves with a collection mapping integrations by their ids.
|
|
@@ -192,7 +192,7 @@ class GuildInvite extends BaseInvite {
|
|
|
192
192
|
if (!guild.members.me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
|
|
193
193
|
return Boolean(
|
|
194
194
|
this.channel?.permissionsFor(this.client.user).has(PermissionFlagsBits.ManageChannels, false) ||
|
|
195
|
-
|
|
195
|
+
guild.members.me.permissions.has(PermissionFlagsBits.ManageGuild),
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -725,8 +725,8 @@ class Message extends Base {
|
|
|
725
725
|
get editable() {
|
|
726
726
|
const precheck = Boolean(
|
|
727
727
|
this.author.id === this.client.user.id &&
|
|
728
|
-
|
|
729
|
-
|
|
728
|
+
(!this.guild || this.channel?.viewable) &&
|
|
729
|
+
this.reference?.type !== MessageReferenceType.Forward,
|
|
730
730
|
);
|
|
731
731
|
|
|
732
732
|
// Regardless of permissions thread messages cannot be edited if
|
|
@@ -837,19 +837,19 @@ class Message extends Base {
|
|
|
837
837
|
const { channel } = this;
|
|
838
838
|
return Boolean(
|
|
839
839
|
channel?.type === ChannelType.GuildAnnouncement &&
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
840
|
+
!this.flags.has(MessageFlags.Crossposted) &&
|
|
841
|
+
this.reference?.type !== MessageReferenceType.Forward &&
|
|
842
|
+
this.type === MessageType.Default &&
|
|
843
|
+
!this.poll &&
|
|
844
|
+
channel.viewable &&
|
|
845
|
+
channel.permissionsFor(this.client.user)?.has(bitfield, false),
|
|
846
846
|
);
|
|
847
847
|
}
|
|
848
848
|
|
|
849
849
|
/**
|
|
850
850
|
* Edits the content of the message.
|
|
851
851
|
*
|
|
852
|
-
* @param {string|
|
|
852
|
+
* @param {string|MessagePayload|MessageEditOptions} options The options to provide
|
|
853
853
|
* @returns {Promise<Message>}
|
|
854
854
|
* @example
|
|
855
855
|
* // Update the content of a message
|
|
@@ -197,13 +197,10 @@ class MessagePayload {
|
|
|
197
197
|
waveform: file.waveform,
|
|
198
198
|
duration_secs: file.duration,
|
|
199
199
|
}));
|
|
200
|
-
|
|
201
|
-
// Only passable during edits
|
|
202
200
|
if (Array.isArray(this.options.attachments)) {
|
|
203
|
-
attachments.push(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
);
|
|
201
|
+
this.options.attachments.push(...(attachments ?? []));
|
|
202
|
+
} else {
|
|
203
|
+
this.options.attachments = attachments;
|
|
207
204
|
}
|
|
208
205
|
|
|
209
206
|
let poll;
|
|
@@ -240,7 +237,7 @@ class MessagePayload {
|
|
|
240
237
|
: allowedMentions,
|
|
241
238
|
flags,
|
|
242
239
|
message_reference,
|
|
243
|
-
attachments,
|
|
240
|
+
attachments: this.options.attachments,
|
|
244
241
|
sticker_ids: this.options.stickers?.map(sticker => sticker.id ?? sticker),
|
|
245
242
|
thread_name: threadName,
|
|
246
243
|
applied_tags: appliedTags,
|
|
@@ -88,7 +88,7 @@ class TextBasedChannel {
|
|
|
88
88
|
* @property {Array<(EmbedBuilder|Embed|APIEmbed)>} [embeds] The embeds for the message
|
|
89
89
|
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
|
|
90
90
|
* (see {@link https://discord.com/developers/docs/resources/message#allowed-mentions-object here} for more details)
|
|
91
|
-
* @property {Array<(Attachment|AttachmentPayload|BufferResolvable
|
|
91
|
+
* @property {Array<(AttachmentBuilder|Attachment|AttachmentPayload|BufferResolvable)>} [files]
|
|
92
92
|
* The files to send with the message.
|
|
93
93
|
* @property {Array<(ActionRowBuilder|MessageTopLevelComponent|APIMessageTopLevelComponent)>} [components]
|
|
94
94
|
* Action rows containing interactive components for the message (buttons, select menus) and other
|
|
@@ -156,7 +156,7 @@ class TextBasedChannel {
|
|
|
156
156
|
/**
|
|
157
157
|
* Sends a message to this channel.
|
|
158
158
|
*
|
|
159
|
-
* @param {string|MessagePayload|MessageCreateOptions
|
|
159
|
+
* @param {string|MessagePayload|MessageCreateOptions} options The options to provide
|
|
160
160
|
* @returns {Promise<Message>}
|
|
161
161
|
* @example
|
|
162
162
|
* // Send a basic message
|
package/src/util/APITypes.js
CHANGED
|
@@ -683,13 +683,3 @@
|
|
|
683
683
|
* @external WebhookType
|
|
684
684
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/WebhookType}
|
|
685
685
|
*/
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* @external RESTPatchAPIChannelMessageJSONBody
|
|
689
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/RESTPatchAPIChannelMessageJSONBody}
|
|
690
|
-
*/
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* @external RESTPostAPIChannelMessageJSONBody
|
|
694
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/RESTPostAPIChannelMessageJSONBody}
|
|
695
|
-
*/
|