djs-selfbot-v13 3.7.13 → 3.7.14
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
CHANGED
|
@@ -157,6 +157,59 @@ class DMChannel extends Channel {
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Search for messages in this DM/Group channel
|
|
162
|
+
* @param {Object} [options] Search options
|
|
163
|
+
* @param {string} [options.authorId] Filter by author ID
|
|
164
|
+
* @param {string[]} [options.has] Filter by attachment type ('image', 'video', 'file', 'sticker', 'embed', 'link')
|
|
165
|
+
* @param {boolean} [options.pinned] Filter pinned messages only
|
|
166
|
+
* @param {string} [options.sortBy='timestamp'] Sort by ('timestamp' or 'relevance')
|
|
167
|
+
* @param {string} [options.sortOrder='desc'] Sort order ('asc' or 'desc')
|
|
168
|
+
* @param {number} [options.offset=0] Pagination offset
|
|
169
|
+
* @param {number} [options.limit] Max number of messages to return
|
|
170
|
+
* @param {Date|number} [options.maxTime] Only return messages before this date
|
|
171
|
+
* @returns {Promise<Object>}
|
|
172
|
+
*/
|
|
173
|
+
async search(options = {}) {
|
|
174
|
+
const {
|
|
175
|
+
authorId,
|
|
176
|
+
has = [],
|
|
177
|
+
pinned,
|
|
178
|
+
sortBy = 'timestamp',
|
|
179
|
+
sortOrder = 'desc',
|
|
180
|
+
offset = 0,
|
|
181
|
+
limit,
|
|
182
|
+
maxTime,
|
|
183
|
+
} = options;
|
|
184
|
+
|
|
185
|
+
const query = {
|
|
186
|
+
sort_by: sortBy,
|
|
187
|
+
sort_order: sortOrder,
|
|
188
|
+
offset,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
if (authorId) query.author_id = authorId;
|
|
192
|
+
if (pinned) query.pinned = true;
|
|
193
|
+
|
|
194
|
+
if (maxTime) {
|
|
195
|
+
const time = new Date(maxTime).getTime();
|
|
196
|
+
const maxId = (BigInt(time) - 1420070400000n) << 22n;
|
|
197
|
+
query.max_id = maxId.toString();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (const hasType of has) {
|
|
201
|
+
if (!query.has) query.has = [];
|
|
202
|
+
query.has.push(hasType);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const data = await this.client.api.channels(this.id).messages.search.get({ query });
|
|
206
|
+
|
|
207
|
+
if (limit && data.messages)
|
|
208
|
+
data.messages = data.messages.flat().slice(0, limit);
|
|
209
|
+
|
|
210
|
+
return data;
|
|
211
|
+
}
|
|
212
|
+
|
|
160
213
|
/**
|
|
161
214
|
* The user in this voice-based channel
|
|
162
215
|
* @type {Collection<Snowflake, User>}
|
|
@@ -204,12 +257,12 @@ class DMChannel extends Channel {
|
|
|
204
257
|
|
|
205
258
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
206
259
|
/* eslint-disable no-empty-function */
|
|
207
|
-
get lastMessage() {}
|
|
208
|
-
get lastPinAt() {}
|
|
209
|
-
send() {}
|
|
210
|
-
sendTyping() {}
|
|
211
|
-
createMessageCollector() {}
|
|
212
|
-
awaitMessages() {}
|
|
260
|
+
get lastMessage() { }
|
|
261
|
+
get lastPinAt() { }
|
|
262
|
+
send() { }
|
|
263
|
+
sendTyping() { }
|
|
264
|
+
createMessageCollector() { }
|
|
265
|
+
awaitMessages() { }
|
|
213
266
|
// Doesn't work on DM channels; setRateLimitPerUser() {}
|
|
214
267
|
// Doesn't work on DM channels; setNSFW() {}
|
|
215
268
|
}
|
|
@@ -314,6 +314,59 @@ class GroupDMChannel extends Channel {
|
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Search for messages in this DM/Group channel
|
|
319
|
+
* @param {Object} [options] Search options
|
|
320
|
+
* @param {string} [options.authorId] Filter by author ID
|
|
321
|
+
* @param {string[]} [options.has] Filter by attachment type ('image', 'video', 'file', 'sticker', 'embed', 'link')
|
|
322
|
+
* @param {boolean} [options.pinned] Filter pinned messages only
|
|
323
|
+
* @param {string} [options.sortBy='timestamp'] Sort by ('timestamp' or 'relevance')
|
|
324
|
+
* @param {string} [options.sortOrder='desc'] Sort order ('asc' or 'desc')
|
|
325
|
+
* @param {number} [options.offset=0] Pagination offset
|
|
326
|
+
* @param {number} [options.limit] Max number of messages to return
|
|
327
|
+
* @param {Date|number} [options.maxTime] Only return messages before this date
|
|
328
|
+
* @returns {Promise<Object>}
|
|
329
|
+
*/
|
|
330
|
+
async search(options = {}) {
|
|
331
|
+
const {
|
|
332
|
+
authorId,
|
|
333
|
+
has = [],
|
|
334
|
+
pinned,
|
|
335
|
+
sortBy = 'timestamp',
|
|
336
|
+
sortOrder = 'desc',
|
|
337
|
+
offset = 0,
|
|
338
|
+
limit,
|
|
339
|
+
maxTime,
|
|
340
|
+
} = options;
|
|
341
|
+
|
|
342
|
+
const query = {
|
|
343
|
+
sort_by: sortBy,
|
|
344
|
+
sort_order: sortOrder,
|
|
345
|
+
offset,
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
if (authorId) query.author_id = authorId;
|
|
349
|
+
if (pinned) query.pinned = true;
|
|
350
|
+
|
|
351
|
+
if (maxTime) {
|
|
352
|
+
const time = new Date(maxTime).getTime();
|
|
353
|
+
const maxId = (BigInt(time) - 1420070400000n) << 22n;
|
|
354
|
+
query.max_id = maxId.toString();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
for (const hasType of has) {
|
|
358
|
+
if (!query.has) query.has = [];
|
|
359
|
+
query.has.push(hasType);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const data = await this.client.api.channels(this.id).messages.search.get({ query });
|
|
363
|
+
|
|
364
|
+
if (limit && data.messages)
|
|
365
|
+
data.messages = data.messages.flat().slice(0, limit);
|
|
366
|
+
|
|
367
|
+
return data;
|
|
368
|
+
}
|
|
369
|
+
|
|
317
370
|
/**
|
|
318
371
|
* Sync VoiceState of this Group DMChannel.
|
|
319
372
|
* @returns {undefined}
|
|
@@ -374,12 +427,12 @@ class GroupDMChannel extends Channel {
|
|
|
374
427
|
|
|
375
428
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
376
429
|
/* eslint-disable no-empty-function */
|
|
377
|
-
get lastMessage() {}
|
|
378
|
-
get lastPinAt() {}
|
|
379
|
-
send() {}
|
|
380
|
-
sendTyping() {}
|
|
381
|
-
createMessageCollector() {}
|
|
382
|
-
awaitMessages() {}
|
|
430
|
+
get lastMessage() { }
|
|
431
|
+
get lastPinAt() { }
|
|
432
|
+
send() { }
|
|
433
|
+
sendTyping() { }
|
|
434
|
+
createMessageCollector() { }
|
|
435
|
+
awaitMessages() { }
|
|
383
436
|
// Doesn't work on DM channels; setRateLimitPerUser() {}
|
|
384
437
|
// Doesn't work on DM channels; setNSFW() {}
|
|
385
438
|
}
|
package/src/structures/Guild.js
CHANGED
|
@@ -1746,10 +1746,8 @@ class Guild extends AnonymousGuild {
|
|
|
1746
1746
|
|
|
1747
1747
|
const data = await this.client.api.guilds(this.id).messages.search.get({ query });
|
|
1748
1748
|
|
|
1749
|
-
if (limit && data.messages)
|
|
1750
|
-
// data.messages est souvent un tableau de tableaux dans l'API search
|
|
1749
|
+
if (limit && data.messages)
|
|
1751
1750
|
data.messages = data.messages.flat().slice(0, limit);
|
|
1752
|
-
}
|
|
1753
1751
|
|
|
1754
1752
|
return data;
|
|
1755
1753
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -1567,6 +1567,7 @@ export class DMChannel extends TextBasedChannelMixin(Channel, [
|
|
|
1567
1567
|
public fetch(force?: boolean): Promise<this>;
|
|
1568
1568
|
public acceptMessageRequest(): Promise<this>;
|
|
1569
1569
|
public cancelMessageRequest(): Promise<this>;
|
|
1570
|
+
public search(options?: ChannelSearchOptions, _attempts?: number): Promise<any>;
|
|
1570
1571
|
public sync(): void;
|
|
1571
1572
|
public ring(): Promise<void>;
|
|
1572
1573
|
public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator;
|
|
@@ -3064,6 +3065,7 @@ export class GroupDMChannel extends TextBasedChannelMixin(Channel, [
|
|
|
3064
3065
|
public getInvite(): Promise<Invite>;
|
|
3065
3066
|
public fetchAllInvite(): Promise<Collection<string, Invite>>;
|
|
3066
3067
|
public deleteInvite(invite: InviteResolvable): Promise<this>;
|
|
3068
|
+
public search(options?: ChannelSearchOptions, _attempts?: number): Promise<any>;
|
|
3067
3069
|
public sync(): void;
|
|
3068
3070
|
public ring(recipients?: UserResolvable[]): Promise<void>;
|
|
3069
3071
|
public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator;
|