Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
ReferenceError: client is not defined | client.userSettings = new Collection();

i have coded a discord bot but i have a problem, when i start the bot i have this problem : "ReferenceError: client is not defined", i have downloaded requirements ect...

The client :

client.userSettings = new Collection();

My interactionCreate.js :

// Check the guide at the beginning if you don't understand paths.
const User = require("../Models/User");
const cmd = client.Commands.get(interaction.commandName);
if (cmd) {
  let user = client.userSettings.get(interaction.user.id);
  // If there is no user, create it in the Database as "newUser"
  if (!user) {
    const findUser = await User.findOne({ Id: interaction.user.id });
    if (!findUser) {
      const newUser = await User.create({ Id: interaction.user.id });
      client.userSettings.set(interaction.user.id, newUser);
      user = newUser;
    } else;
  }

  if (cmd.premium && user && !user.isPremium) {
    interaction.followUp(`You are not premium user`);
  } else {
    cmd.run({ client, interaction, args });
  }
}

My User.js :

const mongoose = require("mongoose");

// The heart of the User, here is everything saved that the User does.
// Such as Levels, Courses, Premium, Enrolled, XP, Leaderboard.
const user = mongoose.Schema({
  Id: {
    type: mongoose.SchemaTypes.String,
    required: true,
    unique: true,
  },
  isPremium: {
    type: mongoose.SchemaTypes.Boolean,
    default: false,
  },
  premium: {
    redeemedBy: {
      type: mongoose.SchemaTypes.Array,
      default: null,
    },

    redeemedAt: {
      type: mongoose.SchemaTypes.Number,
      default: null,
    },

    expiresAt: {
      type: mongoose.SchemaTypes.Number,
      default: null,
    },

    plan: {
      type: mongoose.SchemaTypes.String,
      default: null,
    },
  },
});
module.exports = mongoose.model("user", user);

Please help me i very need help pls, thanks you.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Just utilize the client that you've passed to your commad:

  if (cmd.premium && user && !user.isPremium) {
    interaction.followUp(`You are not premium user`);
  } else {
    cmd.run({ **client**, interaction, args });
  }
}

Also it'd be good to see how your command looks.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The issue is you do not have your client defined in your interactionCreate.js. To define it, use const client = <something> if you need help with client, read this documentation.

If you are new to DiscordJS V13, you can view the docs here

Other steps you can do to trouble shoot is to reinstall discordjs and verify that you are using node version 16 and higher.

Node: In your terminal put node -v

Discord Js Reinstall: In your terminal put npm uninstall discord.js then npm install discord.js or npm install discord.js@13.6.0

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda