Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

80
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda