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

90
Views
Cree una invitación desde el servidor 1 y envíela al usuario DMS en el servidor 2

Entonces, estoy tratando de crear un tipo de comando que generará 1 uso único en el servidor 1. Ahora, si tuviera que ingresar este comando en un texto general en el servidor 2, !dminvite @user , enviaría al usuario mencionado el único creado invite desde el servidor 1 y envíelo al usuario mencionado en el servidor 2, a través de DM.

Algunas notas:

1. Tengo los 2 ID de servidor guardados en mi archivo config.json y este comando de invitación requiere config.json. En esta base de archivos de comandos

2. Este comando se ejecuta en discord.js v12, pero si alguien quiere ayudar en discord.js v13, también sería increíble.

3. No tengo forma de intentar publicitar nada, soy dueño de ambos servidores.

Tengo un código escrito pero no funciona, solo un punto de vista:

 message.delete(); message.mentions.members.first() || message.guild.members.cache.get(args[0]); const Options = { temporary: false, maxAge: 0, maxUses: 1, unique: true }; const channel = message.guild.channels.cache.get('(Channel ID)'); let invite = message.channels.createInvite(Options).then(function(Invite) { message.mentions.members.first().send({embed: { title: `**INVITE**`, description: `Invite:\nhttps://discord.gg/` + Invite.code }}); message.channel.send(new Discord.MessageEmbed() .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true })) .setDescription(`${message.author.tag}, invite was sent to DMs`) .setColor('BLUE') ); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para lograr su objetivo hacemos esto:

  1. Obtenga el usuario mencionado del mensaje.
  2. Busca el otro gremio al que queremos invitar al usuario.
  3. Crea una invitación al canal del sistema del otro gremio (no tiene que ser systemChannel ).
  4. Envía la invitación a los DM del usuario mencionado.
 // Id of the other guild const otherGuildId = "guild id"; client.on("message", async (message) => { // Don't reply to itself if (message.author.id == client.user.id) return; // Check if the message starts with our command if (message.content.startsWith("!dminvite")) { // Get the mentioned user from the message const user = message.mentions.users.first(); if (!user) { message.channel.send("You need to mention the user to send the invitation to."); return; } // Fetch the other guild we want to invite the user to const otherGuild = await client.guilds.fetch(otherGuildId); // Create invite to the other guild's system channel const invite = await otherGuild.systemChannel.createInvite({ maxAge: 0, maxUses: 1, unique: true }); // Send the invite to the mentioned user's DMs user.send({ embed: { title: "**INVITE**", description: `${invite}` } }); } });

Tenga en cuenta que si no desea utilizar systemChannel , simplemente puede obtener cualquier canal que desee del otherGuild por su id, por ejemplo.

 // Resolve channel id into a Channel object const channel = otherGuild.channels.resolve("channel id");

Usando discord.js ^12.5.3 .

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!