Add clear_chat
This commit is contained in:
parent
e830f0deb1
commit
4cc3040180
|
@ -725,6 +725,16 @@ export class Channel extends EventEmitter {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async clearChat() {
|
||||
this.chatHistory = [];
|
||||
await saveChatHistory(this.getID(), this.chatHistory);
|
||||
|
||||
this.sendArray([{
|
||||
m: "c",
|
||||
c: this.chatHistory
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
export default Channel;
|
||||
|
|
|
@ -94,7 +94,7 @@ declare type CustomTarget = {
|
|||
mode: "id";
|
||||
id: string;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
declare interface Crown {
|
||||
userId: string;
|
||||
|
@ -230,6 +230,10 @@ declare interface ServerEvents {
|
|||
key: keyof UserFlags;
|
||||
value: UserFlags[keyof UserFlags];
|
||||
};
|
||||
|
||||
clear_chat: {
|
||||
m: "clear_chat"
|
||||
}
|
||||
}
|
||||
|
||||
declare interface ClientEvents {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import { ServerEventListener } from "../../../../util/types";
|
||||
|
||||
export const clear_chat: ServerEventListener<"clear_chat"> = {
|
||||
id: "clear_chat",
|
||||
callback: async (msg, socket) => {
|
||||
// Reset chat in channel
|
||||
const ch = socket.getCurrentChannel();
|
||||
if (!ch) return;
|
||||
|
||||
await ch.clearChat();
|
||||
}
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { EventGroup, eventGroups } from "../../events";
|
||||
import { clear_chat } from "./handlers/clear_chat";
|
||||
|
||||
export const EVENT_GROUP_ADMIN = new EventGroup("admin");
|
||||
|
||||
|
@ -10,6 +11,6 @@ import { user_flag } from "./handlers/user_flag";
|
|||
// EVENT_GROUP_ADMIN.add(name);
|
||||
// EVENT_GROUP_ADMIN.add(user_flag);
|
||||
|
||||
EVENT_GROUP_ADMIN.addMany(color, name, user_flag);
|
||||
EVENT_GROUP_ADMIN.addMany(color, name, user_flag, clear_chat);
|
||||
|
||||
eventGroups.push(EVENT_GROUP_ADMIN);
|
||||
|
|
Loading…
Reference in New Issue