Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
¿Cómo hacer que le dé a cada boleto un número único?, Discord.js

Cómo funciona:

Estoy tratando de hacer que si alguien reacciona al mensaje que envía un miembro del personal, se abre un ticket.

El problema:

Quería usar la identificación del miembro, pero es demasiado grande. Traté de usar el nombre del jugador, no lo encuentra como canal por alguna razón, ¿quizás un número único es mejor?

Estoy usando un sistema de manejo de comandos, por lo que no verá ninguna de las cosas básicas (por ejemplo client.login )

Aquí está mi código:

 const { Discord } = require('discord.js'); const axios = require("axios") module.exports = { name: 'thing', category: 'Owner', aliases: ["t"], description: 'thing command.', usage: 'thing', userperms: [], botperms: [], run: async (client, message, args) => { message.channel.send('Click "⚔" to open a ticket!').then(function(message) { message.react('⚔'); const filter = (reaction, user) => { return ['⚔'].includes(reaction.emoji.name) && user.id === message.author.id; }}); client.on('messageReactionAdd', (reaction, ruser) => { if (!ruser.bot) { if (reaction.emoji.name == '⚔') { if(message.guild.channels.cache.find(channel => channel.name == (`t-${ruser.id}`))) { return message.channel.send('<@' + ruser.id + '> you already have a ticket, please close your existing ticket first before opening a new one!') .then(m => m.delete({timeout: 3000})); } message.guild.channels.create(`t-${ruser.id}`, { permissionOverwrites: [ { id: message.author.id, allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { message.channel.send(`<@` + ruser.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`) .then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + ruser.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'server-logs'); if(logchannel) { logchannel.send(`Ticket-${ruser.username} created. Click the following to veiw <#${channel.id}>`); } }); } }}); }}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Hay múltiples formas de hacer esto. Crearía un objeto <Map> cuyas claves deberían representar la identificación del usuario y valores la identificación del ticket que pertenece a ese usuario. También declararía un ticketID variable que se incrementaría en 1 cada vez que se creara un nuevo ticket. En cada reacción, el bot debe verificar si la ID de usuario es una clave existente del mapa y, de no ser así, debe crear una nueva entrada en él:

 (...) let ticketCounter = 0; const userTickets = new Map(); client.on('messageReactionAdd', (reaction, ruser) => { if(!ruser.bot) { if(reaction.emoji.name == '⚔') { if(userTickets.has(ruser.id)) { return message.channel.send('<@' + ruser.id + '> you already have a ticket, please close your existing ticket first before opening a new one!').then(m => m.delete({timeout: 3000})); } message.guild.channels.create(`t-${ticketCounter}`, { permissionOverwrites: [ { id: message.author.id, allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { userTickets.set(ruser.id, ticketCounter++); // This will create the map entry whose value is the previous ticketCounter value, the ++ increments afterwards. message.channel.send(`<@` + ruser.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`).then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + ruser.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'server-logs'); if(logchannel) { logchannel.send(`Ticket-${ruser.username} created. Click the following to veiw <#${channel.id}>`); } }); } } });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda