i have a problem with the messageCollector
const msgFilter = (msg) => msg.author.id == message.author.id;
const collector = message.channel.createMessageCollector(msgFilter);
collector.on("collect", (msg) => {
Health = 100
if(msg.content === "punch") {
Health -= 10
}
console.log(Health)
when i type punch the result is 90 but when i type punch again the result is also 90, but it should be 80 I don't have this problem if i create the variable Health outside the messageCollector, but for my usage it must be inside of the messageCollector how can i make it, that every time i type punch 10 get removed?
It must be messagecollector and no other function, because it has to repeat every code inside the messagecollector
A message collector doesn't take an argument of a filter; it takes an argument of MessageCollectorOptions, which includes the filter. You would have to do something like this:
const collector = message.channel.createMessageCollector({
filter: msgFilter
});