Skip to content

Commit 910ab7d

Browse files
committed
✨ Remove player data when they are banned
Resolves #114
1 parent 948b3e1 commit 910ab7d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/helpers/functions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import discord from "discord.js";
1111
import fs from "fs";
1212
import { BannedPlayers, ExtraBans } from "./sqlitedb";
1313
import { FactorioServer } from "../types";
14+
import UserModel from "../base/User";
15+
import { mongoose } from "@typegoose/typegoose";
1416

1517
export type ArgumentTypes<F extends Function> = F extends (args: infer A) => any
1618
? A
@@ -208,6 +210,17 @@ export async function addban(playername: string, reason: string) {
208210
reason: reason || "No reason given",
209211
});
210212

213+
UserModel.deleteMany({factorioName: playername}).exec()
214+
mongoose.connections[1]
215+
.getClient()
216+
.db("scenario")
217+
.collections()
218+
.then((collections) => {
219+
collections.map((collection) => {
220+
collection.deleteMany({playername: playername})
221+
})
222+
})
223+
211224
return player;
212225
}
213226

0 commit comments

Comments
 (0)