Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

550
Views
Discord Bot ReferenceError: El cliente no está definido

Sigo recibiendo este error;

 ReferenceError: client is not defined at Object.<anonymous> (C:\Users\aggie\Downloads\Bot\bot.js:3:1) ←[90m at Module._compile (internal/modules/cjs/loader.js:1085:14)←[39m ←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)←[39m ←[90m at Module.load (internal/modules/cjs/loader.js:950:32)←[39m ←[90m at Function.Module._load (internal/modules/cjs/loader.js:790:12)←[39m ←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m ←[90m at internal/main/run_main_module.js:17:47←[39m

Mi código bot.js es

 let ratelimits = []; client.on("message", (msg) => { // APPLYING RATELIMITS const appliedRatelimit = ratelimits.find( (value) => value.user === msg.author.id && value.channel === msg.channel.id ); if (appliedRatelimit) { // Can they post the message? const canPostMessage = msg.createdAt.getTime() - appliedRatelimit.ratelimit >= appliedRatelimit.lastMessage; // They can if (canPostMessage) return (ratelimits[ ratelimits.indexOf(appliedRatelimit) ].lastMessage = msg.createdAt.getTime()); // They can't msg.delete({ reason: "Enforcing ratelimit." }); } // SET RATELIMIT if (msg.content === "!ratelimit") { // Checking it's you if (msg.author.id !== "705923685877415979") return msg.reply("ok."); // You can change these values in function of the received message const targetedUserId = "529395455109627925"; const targetedChannelId = msg.channel.id; const msRateLimit = 25000; // 25 seconds // Delete existant ratelimit if any for this user on this channel ratelimits = ratelimits.filter( (value) => !( value.user === targetedUserId && value.channel === targetedChannelId ) ); // Add ratelimit ratelimits.push({ user: targetedUserId, channel: targetedChannelId, ratelimit: msRateLimit, lastMessage: 0, }); } // CLEAR RATELIMITS if (msg.content === "!clearRatelimits") { // Checking it's you if (msg.author.id !== "your id") return msg.reply("You can't do that."); // Clearing all ratelimits ratelimits = []; } });

Quería poner el modo lento a ciertos usuarios porque siguen enviando spam al chat, ¿qué estoy haciendo mal? Lo siento si me perdí algo obvio, es la primera vez que hago un bot. Lo copié de una publicación aquí porque todavía soy un principiante en javascript.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En la parte superior de su código, agregue

 const Discord = require('discord.js') const client = new Discord.Client()

Si tiene algún otro problema, consulte la discord.js guide

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!