discord.js 15.0.0-dev.1765065716-5e6bd4b3d → 15.0.0-dev.1765238522-f38395ec4
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 +9 -9
- package/src/index.js +0 -1
- package/src/managers/ChannelManager.js +10 -7
- package/src/managers/MessageManager.js +16 -9
- package/src/structures/Message.js +1 -1
- package/src/structures/MessagePayload.js +7 -4
- package/src/structures/interfaces/TextBasedChannel.js +2 -2
- package/src/util/APITypes.js +10 -0
- package/typings/index.d.mts +30 -39
- package/typings/index.d.ts +30 -39
- package/src/structures/AttachmentBuilder.js +0 -185
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-dev.
|
|
4
|
+
"version": "15.0.0-dev.1765238522-f38395ec4",
|
|
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",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"magic-bytes.js": "^1.12.1",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
63
|
"undici": "7.16.0",
|
|
64
|
-
"@discordjs/builders": "2.0.0-dev.
|
|
65
|
-
"@discordjs/collection": "3.0.0-dev.
|
|
66
|
-
"@discordjs/
|
|
67
|
-
"@discordjs/
|
|
68
|
-
"@discordjs/ws": "3.0.0-dev.
|
|
69
|
-
"@discordjs/util": "2.0.0-dev.
|
|
64
|
+
"@discordjs/builders": "2.0.0-dev.1765238522-f38395ec4",
|
|
65
|
+
"@discordjs/collection": "3.0.0-dev.1765238522-f38395ec4",
|
|
66
|
+
"@discordjs/rest": "3.0.0-dev.1765238522-f38395ec4",
|
|
67
|
+
"@discordjs/formatters": "1.0.0-dev.1765238522-f38395ec4",
|
|
68
|
+
"@discordjs/ws": "3.0.0-dev.1765238522-f38395ec4",
|
|
69
|
+
"@discordjs/util": "2.0.0-dev.1765238522-f38395ec4"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@favware/cliff-jumper": "^6.0.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"turbo": "^2.6.3",
|
|
84
84
|
"typescript": "~5.9.3",
|
|
85
85
|
"@discordjs/api-extractor": "7.52.7",
|
|
86
|
-
"@discordjs/
|
|
87
|
-
"@discordjs/
|
|
86
|
+
"@discordjs/scripts": "0.1.0",
|
|
87
|
+
"@discordjs/docgen": "0.12.1"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22.12.0"
|
package/src/index.js
CHANGED
|
@@ -111,7 +111,6 @@ 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;
|
|
115
114
|
exports.AutocompleteInteraction = require('./structures/AutocompleteInteraction.js').AutocompleteInteraction;
|
|
116
115
|
exports.AutoModerationActionExecution =
|
|
117
116
|
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 } = require('@discordjs/util');
|
|
4
|
+
const { lazy, isFileBodyEncodable, isJSONEncodable } = 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} options The options to provide
|
|
150
|
+
* @param {string|MessagePayload|MessageCreateOptions|JSONEncodable<RESTPostAPIChannelMessageJSONBody>|FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>} options The options to provide
|
|
151
151
|
* @returns {Promise<Message>}
|
|
152
152
|
* @example
|
|
153
153
|
* // Send a basic message
|
|
@@ -174,18 +174,21 @@ class ChannelManager extends CachedManager {
|
|
|
174
174
|
* .catch(console.error);
|
|
175
175
|
*/
|
|
176
176
|
async createMessage(channel, options) {
|
|
177
|
-
let
|
|
177
|
+
let payload;
|
|
178
178
|
|
|
179
179
|
if (options instanceof MessagePayload) {
|
|
180
|
-
|
|
180
|
+
payload = await options.resolveBody().resolveFiles();
|
|
181
|
+
} else if (isFileBodyEncodable(options)) {
|
|
182
|
+
payload = options.toFileBody();
|
|
183
|
+
} else if (isJSONEncodable(options)) {
|
|
184
|
+
payload = { body: options.toJSON() };
|
|
181
185
|
} else {
|
|
182
|
-
|
|
186
|
+
payload = await MessagePayload.create(this, options).resolveBody().resolveFiles();
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
const resolvedChannelId = this.resolveId(channel);
|
|
186
190
|
const resolvedChannel = this.resolve(channel);
|
|
187
|
-
const
|
|
188
|
-
const data = await this.client.rest.post(Routes.channelMessages(resolvedChannelId), { body, files });
|
|
191
|
+
const data = await this.client.rest.post(Routes.channelMessages(resolvedChannelId), payload);
|
|
189
192
|
|
|
190
193
|
return resolvedChannel?.messages._add(data) ?? new (getMessage())(this.client, data);
|
|
191
194
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { makeURLSearchParams } = require('@discordjs/rest');
|
|
5
|
+
const { isFileBodyEncodable, isJSONEncodable } = require('@discordjs/util');
|
|
5
6
|
const { Routes } = require('discord-api-types/v10');
|
|
6
7
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
|
|
7
8
|
const { Message } = require('../structures/Message.js');
|
|
@@ -223,21 +224,27 @@ class MessageManager extends CachedManager {
|
|
|
223
224
|
* Edits a message, even if it's not cached.
|
|
224
225
|
*
|
|
225
226
|
* @param {MessageResolvable} message The message to edit
|
|
226
|
-
* @param {string|MessageEditOptions|MessagePayload} options The options to edit the message
|
|
227
|
+
* @param {string|MessageEditOptions|MessagePayload|FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>|JSONEncodable<RESTPatchAPIChannelMessageJSONBody>} options The options to edit the message
|
|
227
228
|
* @returns {Promise<Message>}
|
|
228
229
|
*/
|
|
229
230
|
async edit(message, options) {
|
|
230
231
|
const messageId = this.resolveId(message);
|
|
231
232
|
if (!messageId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
|
|
232
233
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
.
|
|
240
|
-
|
|
234
|
+
let payload;
|
|
235
|
+
if (options instanceof MessagePayload) {
|
|
236
|
+
payload = await options.resolveBody().resolveFiles();
|
|
237
|
+
} else if (isFileBodyEncodable(options)) {
|
|
238
|
+
payload = options.toFileBody();
|
|
239
|
+
} else if (isJSONEncodable(options)) {
|
|
240
|
+
payload = { body: options.toJSON() };
|
|
241
|
+
} else {
|
|
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);
|
|
241
248
|
|
|
242
249
|
const existing = this.cache.get(messageId);
|
|
243
250
|
if (existing) {
|
|
@@ -849,7 +849,7 @@ class Message extends Base {
|
|
|
849
849
|
/**
|
|
850
850
|
* Edits the content of the message.
|
|
851
851
|
*
|
|
852
|
-
* @param {string|MessagePayload|
|
|
852
|
+
* @param {string|MessageEditOptions|MessagePayload|FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>|JSONEncodable<RESTPatchAPIChannelMessageJSONBody>} options The options to provide
|
|
853
853
|
* @returns {Promise<Message>}
|
|
854
854
|
* @example
|
|
855
855
|
* // Update the content of a message
|
|
@@ -197,10 +197,13 @@ class MessagePayload {
|
|
|
197
197
|
waveform: file.waveform,
|
|
198
198
|
duration_secs: file.duration,
|
|
199
199
|
}));
|
|
200
|
+
|
|
201
|
+
// Only passable during edits
|
|
200
202
|
if (Array.isArray(this.options.attachments)) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
attachments.push(
|
|
204
|
+
// Note how we don't check for file body encodable, since we aren't expecting file data here
|
|
205
|
+
...this.options.attachments.map(attachment => (isJSONEncodable(attachment) ? attachment.toJSON() : attachment)),
|
|
206
|
+
);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
let poll;
|
|
@@ -237,7 +240,7 @@ class MessagePayload {
|
|
|
237
240
|
: allowedMentions,
|
|
238
241
|
flags,
|
|
239
242
|
message_reference,
|
|
240
|
-
attachments
|
|
243
|
+
attachments,
|
|
241
244
|
sticker_ids: this.options.stickers?.map(sticker => sticker.id ?? sticker),
|
|
242
245
|
thread_name: threadName,
|
|
243
246
|
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<(
|
|
91
|
+
* @property {Array<(Attachment|AttachmentPayload|BufferResolvable|FileBodyEncodable<APIAttachment>|Stream)>} [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} options The options to provide
|
|
159
|
+
* @param {string|MessagePayload|MessageCreateOptions|JSONEncodable<RESTPostAPIChannelMessageJSONBody>|FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>} 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,3 +683,13 @@
|
|
|
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
|
+
*/
|
package/typings/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { MessagePort, Worker } from 'node:worker_threads';
|
|
|
5
5
|
import { ApplicationCommandOptionAllowedChannelType, MessageActionRowComponentBuilder } from '@discordjs/builders';
|
|
6
6
|
import { Collection, ReadonlyCollection } from '@discordjs/collection';
|
|
7
7
|
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions, EmojiURLOptions } from '@discordjs/rest';
|
|
8
|
-
import { Awaitable, JSONEncodable } from '@discordjs/util';
|
|
8
|
+
import { Awaitable, FileBodyEncodable, JSONEncodable } from '@discordjs/util';
|
|
9
9
|
import { WebSocketManager, WebSocketManagerOptions } from '@discordjs/ws';
|
|
10
10
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
11
11
|
import {
|
|
@@ -2235,7 +2235,12 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|
|
2235
2235
|
): InteractionCollector<MappedInteractionTypes<InGuild>[ComponentType]>;
|
|
2236
2236
|
public delete(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
2237
2237
|
public edit(
|
|
2238
|
-
content:
|
|
2238
|
+
content:
|
|
2239
|
+
| FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
2240
|
+
| JSONEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
2241
|
+
| MessageEditOptions
|
|
2242
|
+
| MessagePayload
|
|
2243
|
+
| string,
|
|
2239
2244
|
): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
2240
2245
|
public equals(message: Message, rawData: unknown): boolean;
|
|
2241
2246
|
public fetchReference(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
@@ -2260,26 +2265,6 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|
|
2260
2265
|
public inGuild(): this is Message<true>;
|
|
2261
2266
|
}
|
|
2262
2267
|
|
|
2263
|
-
export class AttachmentBuilder {
|
|
2264
|
-
public constructor(attachment: BufferResolvable | Stream, data?: AttachmentData);
|
|
2265
|
-
public attachment: BufferResolvable | Stream;
|
|
2266
|
-
public description: string | null;
|
|
2267
|
-
public name: string | null;
|
|
2268
|
-
public title: string | null;
|
|
2269
|
-
public waveform: string | null;
|
|
2270
|
-
public duration: number | null;
|
|
2271
|
-
public get spoiler(): boolean;
|
|
2272
|
-
public setDescription(description: string): this;
|
|
2273
|
-
public setFile(attachment: BufferResolvable | Stream, name?: string): this;
|
|
2274
|
-
public setName(name: string): this;
|
|
2275
|
-
public setTitle(title: string): this;
|
|
2276
|
-
public setWaveform(waveform: string): this;
|
|
2277
|
-
public setDuration(duration: number): this;
|
|
2278
|
-
public setSpoiler(spoiler?: boolean): this;
|
|
2279
|
-
public toJSON(): unknown;
|
|
2280
|
-
public static from(other: JSONEncodable<AttachmentPayload>): AttachmentBuilder;
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
2268
|
export class Attachment {
|
|
2284
2269
|
private constructor(data: APIAttachment);
|
|
2285
2270
|
private readonly attachment: BufferResolvable | Stream;
|
|
@@ -4280,7 +4265,12 @@ export class ChannelManager extends CachedManager<Snowflake, Channel, ChannelRes
|
|
|
4280
4265
|
private constructor(client: Client<true>, iterable: Iterable<RawChannelData>);
|
|
4281
4266
|
public createMessage(
|
|
4282
4267
|
channel: Exclude<TextBasedChannelResolvable, PartialGroupDMChannel>,
|
|
4283
|
-
options:
|
|
4268
|
+
options:
|
|
4269
|
+
| FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4270
|
+
| JSONEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4271
|
+
| MessageCreateOptions
|
|
4272
|
+
| MessagePayload
|
|
4273
|
+
| string,
|
|
4284
4274
|
): Promise<OmitPartialGroupDMChannel<Message>>;
|
|
4285
4275
|
public fetch(id: Snowflake, options?: FetchChannelOptions): Promise<Channel | null>;
|
|
4286
4276
|
}
|
|
@@ -4632,7 +4622,12 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
|
|
|
4632
4622
|
public delete(message: MessageResolvable): Promise<void>;
|
|
4633
4623
|
public edit(
|
|
4634
4624
|
message: MessageResolvable,
|
|
4635
|
-
options:
|
|
4625
|
+
options:
|
|
4626
|
+
| FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
4627
|
+
| JSONEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
4628
|
+
| MessageEditOptions
|
|
4629
|
+
| MessagePayload
|
|
4630
|
+
| string,
|
|
4636
4631
|
): Promise<Message<InGuild>>;
|
|
4637
4632
|
public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
|
|
4638
4633
|
public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
|
|
@@ -4809,7 +4804,14 @@ export class VoiceStateManager extends CachedManager<Snowflake, VoiceState, type
|
|
|
4809
4804
|
export type Constructable<Entity> = abstract new (...args: any[]) => Entity;
|
|
4810
4805
|
|
|
4811
4806
|
export interface SendMethod<InGuild extends boolean = boolean> {
|
|
4812
|
-
send(
|
|
4807
|
+
send(
|
|
4808
|
+
options:
|
|
4809
|
+
| FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4810
|
+
| JSONEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4811
|
+
| MessageCreateOptions
|
|
4812
|
+
| MessagePayload
|
|
4813
|
+
| string,
|
|
4814
|
+
): Promise<Message<InGuild>>;
|
|
4813
4815
|
}
|
|
4814
4816
|
|
|
4815
4817
|
export interface PinnableChannelFields {
|
|
@@ -6277,7 +6279,7 @@ export interface GuildEmojiEditOptions {
|
|
|
6277
6279
|
|
|
6278
6280
|
export interface GuildStickerCreateOptions {
|
|
6279
6281
|
description?: string | null;
|
|
6280
|
-
file: AttachmentPayload | BufferResolvable |
|
|
6282
|
+
file: AttachmentPayload | BufferResolvable | Stream;
|
|
6281
6283
|
name: string;
|
|
6282
6284
|
reason?: string;
|
|
6283
6285
|
tags: string;
|
|
@@ -6695,14 +6697,7 @@ export interface BaseMessageOptions {
|
|
|
6695
6697
|
)[];
|
|
6696
6698
|
content?: string;
|
|
6697
6699
|
embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[];
|
|
6698
|
-
files?: readonly (
|
|
6699
|
-
| Attachment
|
|
6700
|
-
| AttachmentBuilder
|
|
6701
|
-
| AttachmentPayload
|
|
6702
|
-
| BufferResolvable
|
|
6703
|
-
| JSONEncodable<APIAttachment>
|
|
6704
|
-
| Stream
|
|
6705
|
-
)[];
|
|
6700
|
+
files?: readonly (Attachment | AttachmentPayload | BufferResolvable | FileBodyEncodable<APIAttachment> | Stream)[];
|
|
6706
6701
|
}
|
|
6707
6702
|
|
|
6708
6703
|
export interface MessageOptionsPoll {
|
|
@@ -6742,12 +6737,8 @@ export interface MessageCreateOptions extends BaseMessageCreateOptions {
|
|
|
6742
6737
|
export interface GuildForumThreadMessageCreateOptions
|
|
6743
6738
|
extends BaseMessageOptions, MessageOptionsFlags, MessageOptionsStickers {}
|
|
6744
6739
|
|
|
6745
|
-
export interface MessageEditAttachmentData {
|
|
6746
|
-
id: Snowflake;
|
|
6747
|
-
}
|
|
6748
|
-
|
|
6749
6740
|
export interface MessageEditOptions extends Omit<BaseMessageOptions, 'content'> {
|
|
6750
|
-
attachments?: readonly (Attachment |
|
|
6741
|
+
attachments?: readonly (Attachment | JSONEncodable<APIAttachment>)[];
|
|
6751
6742
|
content?: string | null;
|
|
6752
6743
|
flags?:
|
|
6753
6744
|
| BitFieldResolvable<
|
package/typings/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { MessagePort, Worker } from 'node:worker_threads';
|
|
|
5
5
|
import { ApplicationCommandOptionAllowedChannelType, MessageActionRowComponentBuilder } from '@discordjs/builders';
|
|
6
6
|
import { Collection, ReadonlyCollection } from '@discordjs/collection';
|
|
7
7
|
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions, EmojiURLOptions } from '@discordjs/rest';
|
|
8
|
-
import { Awaitable, JSONEncodable } from '@discordjs/util';
|
|
8
|
+
import { Awaitable, FileBodyEncodable, JSONEncodable } from '@discordjs/util';
|
|
9
9
|
import { WebSocketManager, WebSocketManagerOptions } from '@discordjs/ws';
|
|
10
10
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
11
11
|
import {
|
|
@@ -2235,7 +2235,12 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|
|
2235
2235
|
): InteractionCollector<MappedInteractionTypes<InGuild>[ComponentType]>;
|
|
2236
2236
|
public delete(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
2237
2237
|
public edit(
|
|
2238
|
-
content:
|
|
2238
|
+
content:
|
|
2239
|
+
| FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
2240
|
+
| JSONEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
2241
|
+
| MessageEditOptions
|
|
2242
|
+
| MessagePayload
|
|
2243
|
+
| string,
|
|
2239
2244
|
): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
2240
2245
|
public equals(message: Message, rawData: unknown): boolean;
|
|
2241
2246
|
public fetchReference(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
|
|
@@ -2260,26 +2265,6 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|
|
2260
2265
|
public inGuild(): this is Message<true>;
|
|
2261
2266
|
}
|
|
2262
2267
|
|
|
2263
|
-
export class AttachmentBuilder {
|
|
2264
|
-
public constructor(attachment: BufferResolvable | Stream, data?: AttachmentData);
|
|
2265
|
-
public attachment: BufferResolvable | Stream;
|
|
2266
|
-
public description: string | null;
|
|
2267
|
-
public name: string | null;
|
|
2268
|
-
public title: string | null;
|
|
2269
|
-
public waveform: string | null;
|
|
2270
|
-
public duration: number | null;
|
|
2271
|
-
public get spoiler(): boolean;
|
|
2272
|
-
public setDescription(description: string): this;
|
|
2273
|
-
public setFile(attachment: BufferResolvable | Stream, name?: string): this;
|
|
2274
|
-
public setName(name: string): this;
|
|
2275
|
-
public setTitle(title: string): this;
|
|
2276
|
-
public setWaveform(waveform: string): this;
|
|
2277
|
-
public setDuration(duration: number): this;
|
|
2278
|
-
public setSpoiler(spoiler?: boolean): this;
|
|
2279
|
-
public toJSON(): unknown;
|
|
2280
|
-
public static from(other: JSONEncodable<AttachmentPayload>): AttachmentBuilder;
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
2268
|
export class Attachment {
|
|
2284
2269
|
private constructor(data: APIAttachment);
|
|
2285
2270
|
private readonly attachment: BufferResolvable | Stream;
|
|
@@ -4280,7 +4265,12 @@ export class ChannelManager extends CachedManager<Snowflake, Channel, ChannelRes
|
|
|
4280
4265
|
private constructor(client: Client<true>, iterable: Iterable<RawChannelData>);
|
|
4281
4266
|
public createMessage(
|
|
4282
4267
|
channel: Exclude<TextBasedChannelResolvable, PartialGroupDMChannel>,
|
|
4283
|
-
options:
|
|
4268
|
+
options:
|
|
4269
|
+
| FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4270
|
+
| JSONEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4271
|
+
| MessageCreateOptions
|
|
4272
|
+
| MessagePayload
|
|
4273
|
+
| string,
|
|
4284
4274
|
): Promise<OmitPartialGroupDMChannel<Message>>;
|
|
4285
4275
|
public fetch(id: Snowflake, options?: FetchChannelOptions): Promise<Channel | null>;
|
|
4286
4276
|
}
|
|
@@ -4632,7 +4622,12 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
|
|
|
4632
4622
|
public delete(message: MessageResolvable): Promise<void>;
|
|
4633
4623
|
public edit(
|
|
4634
4624
|
message: MessageResolvable,
|
|
4635
|
-
options:
|
|
4625
|
+
options:
|
|
4626
|
+
| FileBodyEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
4627
|
+
| JSONEncodable<RESTPatchAPIChannelMessageJSONBody>
|
|
4628
|
+
| MessageEditOptions
|
|
4629
|
+
| MessagePayload
|
|
4630
|
+
| string,
|
|
4636
4631
|
): Promise<Message<InGuild>>;
|
|
4637
4632
|
public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
|
|
4638
4633
|
public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
|
|
@@ -4809,7 +4804,14 @@ export class VoiceStateManager extends CachedManager<Snowflake, VoiceState, type
|
|
|
4809
4804
|
export type Constructable<Entity> = abstract new (...args: any[]) => Entity;
|
|
4810
4805
|
|
|
4811
4806
|
export interface SendMethod<InGuild extends boolean = boolean> {
|
|
4812
|
-
send(
|
|
4807
|
+
send(
|
|
4808
|
+
options:
|
|
4809
|
+
| FileBodyEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4810
|
+
| JSONEncodable<RESTPostAPIChannelMessageJSONBody>
|
|
4811
|
+
| MessageCreateOptions
|
|
4812
|
+
| MessagePayload
|
|
4813
|
+
| string,
|
|
4814
|
+
): Promise<Message<InGuild>>;
|
|
4813
4815
|
}
|
|
4814
4816
|
|
|
4815
4817
|
export interface PinnableChannelFields {
|
|
@@ -6277,7 +6279,7 @@ export interface GuildEmojiEditOptions {
|
|
|
6277
6279
|
|
|
6278
6280
|
export interface GuildStickerCreateOptions {
|
|
6279
6281
|
description?: string | null;
|
|
6280
|
-
file: AttachmentPayload | BufferResolvable |
|
|
6282
|
+
file: AttachmentPayload | BufferResolvable | Stream;
|
|
6281
6283
|
name: string;
|
|
6282
6284
|
reason?: string;
|
|
6283
6285
|
tags: string;
|
|
@@ -6695,14 +6697,7 @@ export interface BaseMessageOptions {
|
|
|
6695
6697
|
)[];
|
|
6696
6698
|
content?: string;
|
|
6697
6699
|
embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[];
|
|
6698
|
-
files?: readonly (
|
|
6699
|
-
| Attachment
|
|
6700
|
-
| AttachmentBuilder
|
|
6701
|
-
| AttachmentPayload
|
|
6702
|
-
| BufferResolvable
|
|
6703
|
-
| JSONEncodable<APIAttachment>
|
|
6704
|
-
| Stream
|
|
6705
|
-
)[];
|
|
6700
|
+
files?: readonly (Attachment | AttachmentPayload | BufferResolvable | FileBodyEncodable<APIAttachment> | Stream)[];
|
|
6706
6701
|
}
|
|
6707
6702
|
|
|
6708
6703
|
export interface MessageOptionsPoll {
|
|
@@ -6742,12 +6737,8 @@ export interface MessageCreateOptions extends BaseMessageCreateOptions {
|
|
|
6742
6737
|
export interface GuildForumThreadMessageCreateOptions
|
|
6743
6738
|
extends BaseMessageOptions, MessageOptionsFlags, MessageOptionsStickers {}
|
|
6744
6739
|
|
|
6745
|
-
export interface MessageEditAttachmentData {
|
|
6746
|
-
id: Snowflake;
|
|
6747
|
-
}
|
|
6748
|
-
|
|
6749
6740
|
export interface MessageEditOptions extends Omit<BaseMessageOptions, 'content'> {
|
|
6750
|
-
attachments?: readonly (Attachment |
|
|
6741
|
+
attachments?: readonly (Attachment | JSONEncodable<APIAttachment>)[];
|
|
6751
6742
|
content?: string | null;
|
|
6752
6743
|
flags?:
|
|
6753
6744
|
| BitFieldResolvable<
|
|
@@ -1,185 +0,0 @@
|
|
|
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
|
-
*/
|