Uhhh trying. TODO: User Command + Chat logs save
This commit is contained in:
parent
41ad34be05
commit
a1f303115f
|
@ -14,6 +14,7 @@ import { findSocketByPartID, socketsBySocketID } from "../ws/Socket";
|
||||||
import Crown from "./Crown";
|
import Crown from "./Crown";
|
||||||
import { ChannelList } from "./ChannelList";
|
import { ChannelList } from "./ChannelList";
|
||||||
import { config } from "./config";
|
import { config } from "./config";
|
||||||
|
import { prisma } from "../data/prisma";
|
||||||
|
|
||||||
interface CachedKickban {
|
interface CachedKickban {
|
||||||
userId: string;
|
userId: string;
|
||||||
|
@ -125,7 +126,6 @@ export class Channel extends EventEmitter {
|
||||||
|
|
||||||
this.sendArray([outgoing]);
|
this.sendArray([outgoing]);
|
||||||
this.chatHistory.push(outgoing);
|
this.chatHistory.push(outgoing);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (msg.message.startsWith("/")) {
|
if (msg.message.startsWith("/")) {
|
||||||
this.emit("command", msg, socket);
|
this.emit("command", msg, socket);
|
||||||
|
|
|
@ -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) {
|
export async function deleteUser(_id: string) {
|
||||||
return await prisma.user.delete({
|
return await prisma.user.delete({
|
||||||
where: { id: _id }
|
where: { id: _id }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ChannelList } from "../../channel/ChannelList";
|
import { ChannelList } from "../../channel/ChannelList";
|
||||||
import { deleteUser } from "../../data/user";
|
import { deleteUser, getUsers } from "../../data/user";
|
||||||
import Command from "./Command";
|
import Command from "./Command";
|
||||||
|
|
||||||
Command.addCommand(
|
Command.addCommand(
|
||||||
|
@ -50,12 +50,27 @@ Command.addCommand(
|
||||||
);
|
);
|
||||||
|
|
||||||
Command.addCommand(
|
Command.addCommand(
|
||||||
new Command(["list", "ls"], "list", async msg => {
|
new Command(["list", "ls"], "list <channels, users>", async msg => {
|
||||||
return (
|
if(msg.args.length > 1) {
|
||||||
"Channels:\n- " +
|
if(msg.args[1] == "channels") {
|
||||||
ChannelList.getList()
|
return (
|
||||||
.map(ch => ch.getID())
|
"Channels:\n- " +
|
||||||
.join("\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>";
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue