blob: 4ea01d2aa8d7338e6768a79d4041eaab8ad77b34 [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001import { MongoClient } from "mongodb";
pineafan4edb7762022-06-26 19:21:04 +01002
pineafan63fc5e22022-08-04 22:04:10 +01003const mongoClient = new MongoClient("mongodb://127.0.0.1:27017/local");
4await mongoClient.connect();
pineafan4edb7762022-06-26 19:21:04 +01005const database = mongoClient.db("Nucleus");
6const collection = database.collection("history");
7
8for (let i = 0; i < 100; i++) {
9 // Select a type
Skyler Grey75ea9172022-08-06 10:22:23 +010010 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)];
pineafan4edb7762022-06-26 19:21:04 +010022 // Select a random date in the last year
Skyler Grey75ea9172022-08-06 10:22:23 +010023 let date = new Date(
24 new Date().getTime() - Math.floor(Math.random() * 31536000000)
25 );
pineafan4edb7762022-06-26 19:21:04 +010026 // Add to database
27 await collection.insertOne({
28 type: type,
29 occurredAt: date,
30 user: "438733159748599813",
31 guild: "864185037078790195",
Skyler Grey75ea9172022-08-06 10:22:23 +010032 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
pineafan4edb7762022-06-26 19:21:04 +010057 });
58 console.log("Inserted document " + i);
59}