pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 1 | import { MongoClient } from 'mongodb'; |
| 2 | |
| 3 | const mongoClient = new MongoClient('mongodb://127.0.0.1:27017/local'); |
| 4 | await mongoClient.connect() |
| 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 |
| 10 | let type = ["join", "unban", "leave", "ban", "softban", "kick", "mute", "purge", "warn", "nickname"][Math.floor(Math.random() * 9)]; |
| 11 | // Select a random date in the last year |
| 12 | let date = new Date(new Date().getTime() - Math.floor(Math.random() * 31536000000)); |
| 13 | // Add to database |
| 14 | await collection.insertOne({ |
| 15 | type: type, |
| 16 | occurredAt: date, |
| 17 | user: "438733159748599813", |
| 18 | guild: "864185037078790195", |
| 19 | moderator: (["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type)) ? "438733159748599813" : null, |
| 20 | reason: (["unban", "ban", "softban", "kick", "mute", "purge", "warn"].includes(type)) ? "Test" : null, |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 21 | before: (type === "nickname") ? "TestBefore" : null, |
| 22 | after: (type === "nickname") ? "TestAfter" : null, |
| 23 | amount: (type === "purge") ? Math.floor(Math.random() * 100) : null, |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 24 | }); |
| 25 | console.log("Inserted document " + i); |
| 26 | } |