Added !clear command

This commit is contained in:
rainbow napkin 2024-12-10 18:51:21 -05:00
parent df18b4d783
commit f8efe5b99e
6 changed files with 79 additions and 14 deletions

View file

@ -71,8 +71,22 @@ class chatBox{
}
defineListeners(){
this.client.socket.on("chatMessage", (data) => {
this.displayChat(data);
this.client.socket.on("chatMessage", this.displayChat.bind(this));
this.client.socket.on("clearChat", this.clearChat.bind(this));
}
clearChat(data){
//If we where passed a user to check
if(data.user != null){
var clearedChats = document.querySelectorAll(`.chat-entry-${data.user}`);
}else{
var clearedChats = document.querySelectorAll('.chat-entry');
}
//For each chat found
clearedChats.forEach((chat) => {
//fuckin' nukem!
chat.remove();
});
}