discord-message-transcript 1.1.7-dev.0 → 1.1.7
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TextBasedChannel } from "discord.js";
|
|
2
2
|
import { JsonAuthor, JsonMessage, TranscriptOptionsBase } from "discord-message-transcript-base";
|
|
3
3
|
import { MapMentions } from "../types/types.js";
|
|
4
|
-
export declare function fetchMessages(channel: TextBasedChannel, options: TranscriptOptionsBase, authors: Map<string, JsonAuthor>, mentions: MapMentions,
|
|
4
|
+
export declare function fetchMessages(channel: TextBasedChannel, options: TranscriptOptionsBase, authors: Map<string, JsonAuthor>, mentions: MapMentions, before?: string): Promise<{
|
|
5
5
|
messages: JsonMessage[];
|
|
6
6
|
end: boolean;
|
|
7
|
+
lastMessageId?: string;
|
|
7
8
|
}>;
|
|
@@ -3,8 +3,8 @@ import { componentsToJson } from "./componentToJson.js";
|
|
|
3
3
|
import { urlToBase64 } from "./imageToBase64.js";
|
|
4
4
|
import { CustomError } from "discord-message-transcript-base";
|
|
5
5
|
import { getMentions } from "./getMentions.js";
|
|
6
|
-
export async function fetchMessages(channel, options, authors, mentions,
|
|
7
|
-
const originalMessages = await channel.messages.fetch({ limit: 100, cache: false,
|
|
6
|
+
export async function fetchMessages(channel, options, authors, mentions, before) {
|
|
7
|
+
const originalMessages = await channel.messages.fetch({ limit: 100, cache: false, before: before });
|
|
8
8
|
const rawMessages = await Promise.all(originalMessages.map(async (message) => {
|
|
9
9
|
let authorAvatar = message.author.displayAvatarURL();
|
|
10
10
|
if (options.saveImages) {
|
|
@@ -146,9 +146,10 @@ export async function fetchMessages(channel, options, authors, mentions, after)
|
|
|
146
146
|
system: message.system,
|
|
147
147
|
};
|
|
148
148
|
}));
|
|
149
|
+
const lastMessageId = originalMessages.last()?.id;
|
|
149
150
|
const messages = rawMessages.filter(m => !(!options.includeEmpty && m.attachments.length == 0 && m.components.length == 0 && m.content == "" && m.embeds.length == 0 && !m.poll));
|
|
150
151
|
const end = originalMessages.size !== 100;
|
|
151
|
-
return { messages, end };
|
|
152
|
+
return { messages, end, lastMessageId };
|
|
152
153
|
}
|
|
153
154
|
function formatTimeLeftPoll(timestamp) {
|
|
154
155
|
const now = new Date();
|
package/dist/index.js
CHANGED
|
@@ -55,9 +55,9 @@ export async function createTranscript(channel, options = {}) {
|
|
|
55
55
|
users: new Map(),
|
|
56
56
|
};
|
|
57
57
|
while (true) {
|
|
58
|
-
const { messages, end } = await fetchMessages(channel, internalOptions, authors, mentions, lastMessageID);
|
|
58
|
+
const { messages, end, lastMessageId } = await fetchMessages(channel, internalOptions, authors, mentions, lastMessageID);
|
|
59
59
|
jsonTranscript.addMessages(messages);
|
|
60
|
-
lastMessageID =
|
|
60
|
+
lastMessageID = lastMessageId;
|
|
61
61
|
if (end || (jsonTranscript.messages.length >= quantity && quantity != 0)) {
|
|
62
62
|
break;
|
|
63
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-message-transcript",
|
|
3
|
-
"version": "1.1.7
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typescript": "^5.9.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"discord-message-transcript-base": "1.1.7
|
|
51
|
+
"discord-message-transcript-base": "^1.1.7"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"discord.js": ">=14.19.0 <15"
|