diff --git a/package.json b/package.json index 1b8c7ac..9a2026e 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "license": "MIT", "dependencies": { "axios": "^1.7.7", + "json-bigint-patch": "^0.0.8", "moment": "^2.30.1", "ts-node-dev": "^2.0.0", "typescript": "^5.5.4" diff --git a/src/index.ts b/src/index.ts index 4946e35..07cab21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,10 +4,19 @@ import { ChannelData } from "./interfaces/channelData"; import { MessageData } from "./interfaces/messageData"; import { MessageDeleteData } from "./interfaces/messageDeleteData"; import moment from "moment"; +import "json-bigint-patch"; const secondsDelay = 2, token = process.argv[2]; +const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +let totalMessages = 0, + totalDeleted = 0; + +const CHANNELS_DATA: ChannelData[] = [], + MESSAGES_DATA: { [key: string]: MessageData[] } = {}; + function getUserIdFromToken(token: string): string { const tokenParts = token.split("."); const payload = tokenParts[0]; @@ -30,20 +39,14 @@ const axiosInstance = axios.create({ }, }); -const deleteMessage = async (channelId: string, messageId: string) => { +const deleteMessage = async (channelId: string, messageId: bigint) => { + console.log(messageId.toString()); + return await axiosInstance.delete( - `/channels/${channelId}/messages/${messageId}` + `/channels/${channelId}/messages/${messageId.toString()}` ); }; -const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); - -let totalMessages = 0, - totalDeleted = 0; - -const CHANNELS_DATA: ChannelData[] = [], - MESSAGES_DATA: { [key: string]: MessageData[] } = {}; - async function main() { const myId = getUserIdFromToken(token); console.log(`My ID: ${myId}`); @@ -87,6 +90,8 @@ async function main() { const messages: MessageData[] = JSON.parse(messagesData.toString()); totalMessages += messages.length; + console.log(messages); + CHANNELS_DATA.push(channelData); MESSAGES_DATA[channelData.id] = JSON.parse(messagesData.toString()); } diff --git a/src/interfaces/messageData.d.ts b/src/interfaces/messageData.d.ts index 12af08e..8950a42 100644 --- a/src/interfaces/messageData.d.ts +++ b/src/interfaces/messageData.d.ts @@ -1,5 +1,5 @@ export interface MessageData { - ID: string; + ID: bigint; Timestamp: string; Contents: string; Attachments: string; diff --git a/src/interfaces/messageDeleteData.d.ts b/src/interfaces/messageDeleteData.d.ts index 44a626f..a7a287e 100644 --- a/src/interfaces/messageDeleteData.d.ts +++ b/src/interfaces/messageDeleteData.d.ts @@ -1,4 +1,4 @@ export interface MessageDeleteData { channel_id: string; - message_id: string; + message_id: bigint; } diff --git a/yarn.lock b/yarn.lock index 928cdca..d1afa41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -288,6 +288,11 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== +json-bigint-patch@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/json-bigint-patch/-/json-bigint-patch-0.0.8.tgz#45d954da1f21c6d4f3ae9ef64c9ac227cd0ab0fe" + integrity sha512-xa0LTQsyaq8awYyZyuUsporWisZFiyqzxGW8CKM3t7oouf0GFAKYJnqAm6e9NLNBQOCtOLvy614DEiRX/rPbnA== + make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"