Does it persist?

So I have an array of muted users. The users should not be able to speak if muted. I made it so if you chat (on my website) but you do /mute the user is muted, thus they shall not speak. I tried to mute “suscat” which is my alt. It couldn’t talk if I manually typed the name in muted but the command itself did nothing. I would like to know if the command doesn’t do anything because it doesn’t persist.

Repl link:
The link:

let muted = ['CoderElijah', 'amasad'];

form.addEventListener('submit', function(e) {
  if (input.value && input.value !== " " && input.value !== "  " && input.value !== "   ") {
    if (input.value.slice(0, 5) === "/mute" && username === owner) {
      let banned = input.value.slice(5);
      input.value = '';
    } else if (!muted.includes(username)) {
      const filteredInput = filterSwearWords(input.value);
      socket.emit('chat message', /* styling for the message + the actual message*/);
      input.value = ''; 
    } else {
      input.value = '';
}); /* I realize that I might have to many curly brackets */

Tip: use String.prototype.trim to remove any leading or trailing whitespaces.

input.value.trim() !== ""

You should handle muting on the server side, use something like a file which will persist to store muted users.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.