fix: patch bigint value

This commit is contained in:
M1000fr 2024-09-06 17:44:57 +02:00
parent a376dedffd
commit 1b982b0b10
5 changed files with 23 additions and 12 deletions

View File

@ -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"

View File

@ -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());
}

View File

@ -1,5 +1,5 @@
export interface MessageData {
ID: string;
ID: bigint;
Timestamp: string;
Contents: string;
Attachments: string;

View File

@ -1,4 +1,4 @@
export interface MessageDeleteData {
channel_id: string;
message_id: string;
message_id: bigint;
}

View File

@ -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"