Wazarr94 / haxball_bot_headless

Ready-to-go scripts and functions for the HaxBall Headless API !
MIT License
46 stars 74 forks source link

unmute by #id is not working #30

Closed tanercanbilgin closed 2 years ago

tanercanbilgin commented 2 years ago

only unmute with mutelist works. can you check it

iwishiknewcoding commented 2 years ago

you need to add something like this in the MuteList class:

    getByPlayerId(id) {
        var index = this.list.findIndex(mutePlayer => mutePlayer.playerId === id);
        if (index !== -1) {
            return this.list[index];
        }
        return null;
    }

and use it like so:

        var playerUnmute = room.getPlayer(parseInt(msgArray[0]));
        if (muteArray.getByPlayerId(playerUnmute.id) != null) {
            var muteObj = muteArray.getByPlayerId(playerUnmute.id);
            muteObj.remove()
            room.sendAnnouncement(
                `${playerUnmute.name} has been unmuted !`,
                null,
                announcementColor,
                'normal',
                HaxNotification.CHAT
            );
            room.setPlayerAvatar(playerUnmute.id, null);
        }

of course the above code needs to be modified to fit into yours.

tanercanbilgin commented 2 years ago

thank you so much, do you have discord?

Wazarr94 commented 2 years ago

thanks @iwishiknewcoding for spotting the mistake, just pushed the suggested fix