Unlurk command not removing lukers from the Array

Hello i have a issue im working on a lurk/ unlurk command with a list of current lurkers
the only problem is that when a viewers lurks it adds him/her to the lurkers list but when the unlurk it doesnt remove them from the list this also comes with the problem that the can not lurk again
here is also a screenshot and the code

(i used the Lurkers Variable in the lurkers command for debugging)

image

var lurkCount = 0;
var lurkers = ;

client.on(‘message’, (channel, tags, message, self) => {
if(self) return;
let theUser = tags.username;
if(message.toLowerCase() === ‘!lurk’) {
if ( lurkers.includes(theUser)) {
console.log(“lurking”);
console.log(lurkers)
} else {
client.say (channel, ${theUser} is watching on the back seat (Dont forget to use ( !back ) when you are back from lurking))
console.log(“not lurking”);
lurkers.push(${tags.username});
console.log(lurkers)
lurkCount = lurkers.length;
}
}
if(message.toLowerCase() === ‘!back’) {
if ( lurkers.includes(theUser)) {
let toRemove = lurkers.indexOf(theUser);
client.say(channel, ${theUser} is back in the front seat!)
} else{
client.say(channel, ${theUser} was not even lurking)

}
}
if(message.toLowerCase() === ‘!lurkers’) {
client.say(channel, ${lurkers} are currently lurking);
};
});

thank you in advance

In the !lurk case, you do lurkers.push() but in the !back case, you don’t do lurkers.splice()

thanks yea i found the issue this morning no idea why it took me 4 months to find the issue XD

but also doesnt fully fix this problem
it works if you users the usernames (lurkers)

but when you try the lurkcount it will stay on 1 lurker some how wont go back to 0

In !lurk, you do lurkCount = lurkers.length; but not in !unlurk. I’d recommend removing lurkCount, if possible, and relying on lurkers.length to be correct (which it will be).

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