Added !clear command
This commit is contained in:
parent
df18b4d783
commit
f8efe5b99e
6 changed files with 79 additions and 14 deletions
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue