Uhhh trying. TODO: User Command + Chat logs save

This commit is contained in:
Daniel 2024-02-03 21:00:15 -03:00
parent 41ad34be05
commit a1f303115f
4 changed files with 31 additions and 9 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -14,6 +14,7 @@ import { findSocketByPartID, socketsBySocketID } from "../ws/Socket";
import Crown from "./Crown";
import { ChannelList } from "./ChannelList";
import { config } from "./config";
import { prisma } from "../data/prisma";
interface CachedKickban {
userId: string;
@ -125,7 +126,6 @@ export class Channel extends EventEmitter {
this.sendArray([outgoing]);
this.chatHistory.push(outgoing);
try {
if (msg.message.startsWith("/")) {
this.emit("command", msg, socket);

View File

@ -13,6 +13,13 @@ export async function createUser(
});
}
export async function getUsers() {
return await {
users: await prisma.user.findMany(),
count: await prisma.user.count()
}
}
export async function deleteUser(_id: string) {
return await prisma.user.delete({
where: { id: _id }

View File

@ -1,5 +1,5 @@
import { ChannelList } from "../../channel/ChannelList";
import { deleteUser } from "../../data/user";
import { deleteUser, getUsers } from "../../data/user";
import Command from "./Command";
Command.addCommand(
@ -50,12 +50,27 @@ Command.addCommand(
);
Command.addCommand(
new Command(["list", "ls"], "list", async msg => {
return (
"Channels:\n- " +
ChannelList.getList()
.map(ch => ch.getID())
.join("\n- ")
);
new Command(["list", "ls"], "list <channels, users>", async msg => {
if(msg.args.length > 1) {
if(msg.args[1] == "channels") {
return (
"Channels:\n- " +
ChannelList.getList()
.map(ch => ch.getID())
.join("\n- ")
);
} else if (msg.args[1] == "users") {
var users = getUsers();
return (
"Users: "+await (await users).count+"\n- " +
(await users).users.forEach(async user => {
`\n- ${user.id}: ${user.name}`
})
);
}
} else {
return "list <channels, users>";
}
})
);