#Banning a user after 3 attempts

23 messages · Page 1 of 1 (latest)

quaint lodge
#

Hi, I'm trying to make a command to ban a user when they type a filtered word 3 times. If they do they get banned. I've done this logic however I've set up a count variable to track the amount of times the user has made the offence. However it just stays at one every time causing for the condition to never be met. Any help will be appreciated 🙂

zealous helm
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

quaint lodge
#

node version: v18.12.1

npm version:
9.1.2

frail blaze
#

which would keep it at 1 forever

#

secondly, this would apply to all users and if it worked correctly user 1 says bad word, 2 says bad word, and 3 says bad word, but 3 will get banned

#

even tho they only said it once

quaint lodge
#

What would be the best way of going about doing this? Or is it not worth the hassle?

frail blaze
#

Id say work with a database, cuz it’s possible that the bot will restart in the middle of a count

#

but u don’t necessarily have to

#

u can utilize javascript maps and store counts with user ids as a key

rain martenBOT
#

mdn Map
The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.

frail blaze
#

or u can use djs collections

quaint lodge
#

something like this?

frail blaze
#

you should check for an existing entry on detected and if@not make one

quaint lodge
#

for some reason my brain is working propely today would you mind giving me an example?

#

@frail blaze

quaint lodge
#

this is another version of the code ive came up with

quaint lodge
#

Still haven't been able to increment the value. All the ways I've tried dont seem to work

wise yacht
#

You make a new Map with every message received. This is not djs related but rather basic JS/coding logic