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

446
Views
¿Cómo puedo actualizar el código de discord.js v12 a v13? - Mensajes de bienvenida

Estaba viendo un tutorial de YouTube sobre mensajes de bienvenida. Copié todo el código, etc. Cuando uso este código en discord.js v13, no funciona. Cuando uso este código en discord.js v12 todo funciona. Bot después de unirse a un nuevo miembro envía un mensaje de bienvenida. En discord.js v13, el bot no dijo nada y no tengo ningún error en la terminal. ¿Puede alguien ayudarme con eso? Soy principiante en la codificación y solo tengo algunos tutoriales. Por favor ayuda.

Aquí está index.js:

 const Discord = require('discord.js'); const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES" , "GUILD_MESSAGE_REACTIONS" , "DIRECT_MESSAGE_REACTIONS" ] , partials: ["MESSAGE" , "CHANNEL" , "REACTION"] }); client.commands = new Discord.Collection(); const fs = require('fs'); const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js')) for(const file of commandFiles){ const command = require(`./commands/${file}`) client.commands.set(command.name, command) } const { prefix, token } = require('./config.json') const welcome = require('./commands/welcome'); // Add This client.once('ready', () => { console.log('Ready.') welcome(client) // Add This }) client.on('message', message => { if(!message.content.startsWith(prefix)||message.author.bot) return const args = message.content.slice(prefix.length).split(/ +/) const command = args.shift().toLowerCase() if(command === 'ping'){ client.commands.get('ping').execute(message, args) } else if(command === 'yt'){ client.commands.get('yt').execute(message, args) } else if(command === 'purge'){ client.commands.get('purge').execute(message, args) } }) client.login(token)

Aquí está bienvenido.js:

 module.exports = (client) => { // Welcome Message Command const welcomechannelId = '' //Channel You Want to Send The Welcome Message const targetChannelId = `` //Channel For Rules client.on('guildMemberAdd', (member) => { console.log(member) const welocmemessage = ` <@${member.id}> Welcome To Our Server, Please Read ${member.guild.channels.cache.get(targetChannelId).toString()} Have A Nice Time!` const channel = member.guild.channels.cache.get(welcomechannelId) channel.send(welocmemessage) }) // Leave Message Command const leavechannelId = '' //Channel You Want to Send The Leave Message client.on('guildMemberRemove', (member) => { const leavemessage = `<@${member.id}> Just Left Server.` const channel1 = member.guild.channels.cache.get(leavechannelId) channel1.send(leavemessage) }) }

Aquí está config.json:

 { "token": "Your-Token", "prefix": "+" }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

En esta línea:

 const Discord = require('discord.js'); const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES" , "GUILD_MESSAGE_REACTIONS" , "DIRECT_MESSAGE_REACTIONS" ] , partials: ["MESSAGE" , "CHANNEL" , "REACTION"] });

Cámbialo por esto:

 const Client = require('discord.js'); const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES" , "GUILD_MESSAGE_REACTIONS" , "DIRECT_MESSAGE_REACTIONS" ] , partials: ["MESSAGE" , "CHANNEL" , "REACTION"] });

Creo que es por eso que no funciona y es mejor usar client.channels.cache.find() así:

 client.on('guildMemberAdd', member => { let channel = client.channels.cache.find(channel => channel.name === "welcome"); const join = new MessageEmbed() .setTitle("Welcome!") .setColor('RANDOM') .setDescription("some descriptions") .setTimestamp() channel.send({embeds: [join]}); });

Puede ser así también:

 client.on('guildMemberAdd', member => { let channel = client.channels.cache.find(channel => channel.name === "welcome"); message.channel.send({content: ""}) //message.channel.send("content") });
about 4 years ago · Juan Pablo Isaza Report

0

Parece que estás usando el código de código lyons, ¡lo cual está bien!

También en discord v13 necesitarías cambiar la forma en que envías mensajes e incrustas... esto es lo que puedes hacer:

 client.on("guildMemberAdd", async (member, guild) => { let channel = client.channels.cache.find(wch => wch.name === "welcome"); let rules = client.channels.cache.find(rch => rch.name === "rules"); const user = member.user; const welcomeEmbed = new MessageEmbed() .setAuthor(`${user.tag}`, user.displayAvatarURL()) .setThumbnail(user.displayAvatarURL()) .setDescription(`Welcome to the server, ${user.tag}`) .setColor("GREEN"); channel.send({ embeds: [welcomeEmbed] }); });

Para cuando un usuario se una a tu servidor ^^

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!