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←[39mMi 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.
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