#How to make a warn with a database

24 messages · Page 1 of 1 (latest)

zenith pewter

that*

swift narwhal

Well, have a user schema for warn data for user, so inside the schema you'll have like an array named warns or however you'd like to customize it,

have a command to warn a user,

inside the command check if the user has data, if not create the data for the warns. If the user has data, push to the warns. After you've pushed to the warns and saved the data, check if the user has 3 warns and then if they do, kick the user. If u want u can clear the warns or whatever you'd like, jus a basic understanding of how I'd do it

zenith pewter

what's a schema?

swift narwhal
swift narwhal
zenith pewter what's a schema?

It's something you add to a model and a model is basically data in mongodb, watch a mongoose mongodb course or tutorial on youtube and when you get a basic understanding, you can attempt and then come here if you need help

zenith pewter

ok thank you, does discordJS docs have a tutorial kind of thing by any chance?

swift narwhal

As for the spamming, when the user sends a message, store the ID of the user in a collection or have like a boolean in the database and when the user sends a message, check if the boolean is truthy or if the user is in the collection. If they are, warn them. After some time, (the cooldown), remove the ID of the user or set the boolean to a falsey value

swift narwhal

You can use prior knowledge in databases , collections, or javascript to make this

zenith pewter

i don't have any knowledge with databases as i've never used one

thank you @swift narwhal 🙂

there are tutorials on youtube so i think that they will help

swift narwhal
swift narwhal
zenith pewter

ok thank you 🙏

ivory badge

There are many databases out there, i'd say the simplest isnt even a database but a json file. Let's go over the basic concepts of this:

When you warn the user, store the userID in a json file. for example:

{
  "234091823091283": {
     "warns": 1
  }
}

increase the warns value each time (you can ofcourse add extra data after the warns value like the amount of kicks or bans or whatever)

Then when you warn the user check the warns and if they reach a certain number ban/kick/do whatever with the user (you get the user by the userID)

I hope you understood my explanation.

zenith pewter
maiden mica
zenith pewter

i think i am going to stick with the json one, sorry

maiden mica

No sweat kk

ivory badge

Well no. Every time someone runs the warn command it just adds to the warns thing

ivory badge

Yes without a database. Pseudo code:
json[USERID][warns] += 1

zenith pewter

i might just follow a tutorial on yt