blob: a2d9bf55363a5e4879fbf22c269cfc1c20f62edb [file] [log] [blame]
pineafan4edb7762022-06-26 19:21:04 +01001import { MongoClient } from 'mongodb';
2
3const mongoClient = new MongoClient('mongodb://127.0.0.1:27017/local');
4await mongoClient.connect()
5const database = mongoClient.db("Nucleus");
6const collection = database.collection("history");
7
8for (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,
21 before: (type == "nickname") ? "TestBefore" : null,
22 after: (type == "nickname") ? "TestAfter" : null,
23 amount: (type == "purge") ? Math.floor(Math.random() * 100) : null,
24 });
25 console.log("Inserted document " + i);
26}