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 | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 10 | let type = [ |
| 11 | "join", |
| 12 | "unban", |
| 13 | "leave", |
| 14 | "ban", |
| 15 | "softban", |
| 16 | "kick", |
| 17 | "mute", |
| 18 | "purge", |
| 19 | "warn", |
| 20 | "nickname" |
| 21 | ][Math.floor(Math.random() * 9)]; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 22 | // Select a random date in the last year |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 23 | let date = new Date( |
| 24 | new Date().getTime() - Math.floor(Math.random() * 31536000000) |
| 25 | ); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 26 | // Add to database |
| 27 | await collection.insertOne({ |
| 28 | type: type, |
| 29 | occurredAt: date, |
| 30 | user: "438733159748599813", |
| 31 | guild: "864185037078790195", |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 32 | moderator: [ |
| 33 | "unban", |
| 34 | "ban", |
| 35 | "softban", |
| 36 | "kick", |
| 37 | "mute", |
| 38 | "purge", |
| 39 | "warn" |
| 40 | ].includes(type) |
| 41 | ? "438733159748599813" |
| 42 | : null, |
| 43 | reason: [ |
| 44 | "unban", |
| 45 | "ban", |
| 46 | "softban", |
| 47 | "kick", |
| 48 | "mute", |
| 49 | "purge", |
| 50 | "warn" |
| 51 | ].includes(type) |
| 52 | ? "Test" |
| 53 | : null, |
| 54 | before: type === "nickname" ? "TestBefore" : null, |
| 55 | after: type === "nickname" ? "TestAfter" : null, |
| 56 | amount: type === "purge" ? Math.floor(Math.random() * 100) : null |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 57 | }); |
| 58 | console.log("Inserted document " + i); |
| 59 | } |