How to create a warn system?

Hello, I would like to know if someone will know how to make a system of warns that will work on several servers. I already have a warn system but it does not register the server or the user has been warn. As an example I would like to do something like this: if I warn someone on my server and I warn him another pars he will have 2 warn instead of having 1 warn on one server and 1 warn another pars. For precision: my warn syste function with enmap.

Can you share your project name or code of your warn system?

If you are saving the warnings in a database you should add the ID of the guild and then make the bot check if the user was warn in that guild

const Command = require("../../modules/Command.js");

const ms = require(“ms”);

class Warn extends Command {
constructor(client) {
super(client, {
name: “warn”,
description: “Commande pour avertir un utilisateur.”,
usage: “warn”,
category: “Système”,
permLevel: “Modérateur”

async run(message, args) {
try {
const warnedUser = message.guild.member(
message.mentions.users.first() || message.guild.members.get(args[0])
if (!warnedUser)
return“L’utilisateur n’existe pas.”);
const warnToAdd = 1;
const warnToDel = 5;
const reason = args.join(" ").slice(22);
this.client.warns.ensure(${}, {
warnings: 0
let userWarnings = this.client.warns.get(${}, “warnings”);
userWarnings += warnToAdd;

  this.client.warns.set(`${}`, userWarnings, "warnings");


  if (this.client.warns.get(`${}`, "warnings") == 1) {
      `${warnedUser}, premier avertissement (raison: ${reason})`
  } else if (this.client.warns.get(`${}`, "warnings") == 2) {
    const muteRole = message.guild.roles.find(x => === "muted");
    if (!muteRole) message.guild.createRole("name", "muted");
      `${warnedUser}, deuxième avertissement (raison: ${reason})`
    const muteTime = "1h";
    await warnedUser.addRole(;
      `${warnedUser} est muté pendant ${muteTime} (raison: ${reason})`

    setTimeout(function() {
      warnedUser.removeRole(;`L'utilisateur ${warnedUser} n'est plus muté !`);
    }, ms(muteTime));
  } else if (this.client.warns.get(`${}`, "warnings") == 3) {`${warnedUser}, troisième avertissement (raison: ${reason})`);`:warning: Attention ${warnedUser}, à 5 avertissement sa sera ban définitif`);
  } else if (this.client.warns.get(`${}`, "warnings") == 4) {`${warnedUser}, quatrième avertissement profite d'un kick (raison: ${reason})`);
  } else if (this.client.warns.get(`${}`, "warnings") == 5) {`${warnedUser}, cinquième avertissement comme je te l'avait dit au cinquième warn j'allais te bannir donc au revoir`);
    userWarnings -= warnToDel;
} catch (e) {


module.exports = Warn;

@cori excuse me for disturbance i have a problem:
I can not indent the code as it should

This is your code:

I can see you save the data with but you should also save the

const warnedGuild = message.guild;

So you will have in your data this: 456789 123456
warnings: 1

Then you can see if the user have a warning in that guild.

I don’t understand can you repeat or correct my code please ? if this not disturb you…

We can’t really do your code for you, that’s spoon feeding. It’s not good to get spoon fed when you’re just beginning, could become a habit to just to get spoon fed later on and you won’t learn much. Honestly though, check out the official discord.js discord and ask for help there, they’ll give quicker support, and lead you in the right direction without spoon feeding. Check it out: