Add deleteallusers readline command
This commit is contained in:
parent
b86d86b3f2
commit
dd73e303a6
2
public
2
public
|
@ -1 +1 @@
|
|||
Subproject commit 1dc00c7f885ac919a1bda7d4c749d33bd594c42f
|
||||
Subproject commit a8a0182686cec166c3042697c639c5ca8b6acf6b
|
|
@ -35,7 +35,7 @@ export async function getUsers() {
|
|||
return {
|
||||
users: await prisma.user.findMany(),
|
||||
count: await prisma.user.count()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function deleteUser(_id: string) {
|
||||
|
@ -44,6 +44,10 @@ export async function deleteUser(_id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function deleteAllUsers() {
|
||||
return await prisma.user.deleteMany();
|
||||
}
|
||||
|
||||
export async function readUser(_id: string) {
|
||||
try {
|
||||
const data = await prisma.user.findUnique({
|
||||
|
|
|
@ -50,9 +50,6 @@ export function createSocketID() {
|
|||
}
|
||||
|
||||
export function createColor(_id: string) {
|
||||
logger.debug(
|
||||
"Creating color for " + _id + " using method " + config.colorGeneration
|
||||
);
|
||||
if (config.colorGeneration == "random") {
|
||||
return "#" + Math.floor(Math.random() * 16777215).toString(16);
|
||||
} else if (config.colorGeneration == "sha256") {
|
||||
|
@ -73,7 +70,6 @@ export function createColor(_id: string) {
|
|||
const g = output.readUInt8(1) + 0x20;
|
||||
const b = output.readUInt8(2);
|
||||
|
||||
logger.debug("Colors:", r, g, b);
|
||||
return (
|
||||
"#" +
|
||||
r.toString(16).padStart(2, "0") +
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { getRoles, giveRole, removeRole } from "~/data/role";
|
||||
import { ChannelList } from "../../channel/ChannelList";
|
||||
import { deleteUser, getUsers } from "../../data/user";
|
||||
import { deleteAllUsers, deleteUser, getUsers } from "../../data/user";
|
||||
import Command from "./Command";
|
||||
import {
|
||||
addRolePermission,
|
||||
|
@ -10,6 +10,7 @@ import {
|
|||
removeRolePermission
|
||||
} from "~/data/permissions";
|
||||
import { builtinTags, removeTag, setBuiltinTag } from "../tags";
|
||||
import logger from "./logger";
|
||||
|
||||
Command.addCommand(
|
||||
new Command(["help", "h", "commands", "cmds"], "help", msg => {
|
||||
|
@ -198,3 +199,16 @@ Command.addCommand(
|
|||
}
|
||||
})
|
||||
);
|
||||
|
||||
Command.addCommand(
|
||||
new Command(["deleteallusers"], "deleteallusers [confirm]", async msg => {
|
||||
if (!msg.args[1])
|
||||
return `Are you sure this is what you want? Type "deleteallusers confirm" to confirm:`;
|
||||
|
||||
if (msg.args[1] !== "confirm") return "Invalid response";
|
||||
|
||||
logger.info("Deletion info:", await deleteAllUsers());
|
||||
|
||||
return "All user data successfully deleted.";
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue