pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 1 | import { MongoClient } from "mongodb"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 2 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 3 | const mongoClient = new MongoClient("mongodb://127.0.0.1:27017/local"); |
| 4 | await mongoClient.connect(); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 5 | const database = mongoClient.db("Nucleus"); |
| 6 | const collection = database.collection("history"); |
| 7 | |
| 8 | for (let i = 0; i < 100; i++) { |
| 9 | // Select a type |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 10 | let type = ["join", "unban", "leave", "ban", "softban", "kick", "mute", "purge", "warn", "nickname"][ |
| 11 | Math.floor(Math.random() * 9) |
| 12 | ]; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 13 | // Select a random date in the last year |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 14 | let date = new Date(Date.now() - Math.floor(Math.random() * 31536000000)); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 15 | // Add to database |
| 16 | await collection.insertOne({ |
| 17 | type: type, |
| 18 | occurredAt: date, |
| 19 | user: "438733159748599813", |
| 20 | guild: "864185037078790195", |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 21 | moderator: ["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | ? "438733159748599813" |
| 23 | : null, |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 24 | reason: ["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type) ? "Test" : null, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 25 | before: type === "nickname" ? "TestBefore" : null, |
| 26 | after: type === "nickname" ? "TestAfter" : null, |
| 27 | amount: type === "purge" ? Math.floor(Math.random() * 100) : null |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 28 | }); |
| 29 | console.log("Inserted document " + i); |
| 30 | } |