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

145
Views
No agregando al mapa, manteniendo el mismo nombre "t-1"

Lo estoy haciendo para que si un miembro dice ~nuevo, crea un nuevo boleto para él, pero el problema es que el nombre del canal tiene que ir en un número único, como t-1, luego t-2, etc.

Pero se queda solo con "t-1", para ser claros, estoy usando un controlador de comandos.

aquí está mi código:

 module.exports = { name: 'new', category: 'Ticket', description: 'Creates a new ticket.', aliases: ['newticket'], usage: 'new', userperms: [], botperms: [], run: async (client, message, args) => { let ticketCounter = 1; const userTickets = new Map() if(userTickets.has(message.author.tag)) { return message.channel.send('<@' + message.author.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: "916785912267034674", allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { channel.setParent('916778691672031293'); userTickets.set(message.author.id, ticketCounter++); message.channel.send(`<@` + message.author.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`).then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + message.author.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'test'); if(logchannel) { logchannel.send(`Ticket-${ticketCounter} created. Click the following to veiw <#${channel.id}>`); } }); } }

¡Gracias!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Use <Map>.size en lugar de un incrementador ya que el código se vuelve a ejecutar después de cada comando, el contador se establecerá en 1 cada vez.

 if(!client.userTickets) client.userTickets = new Map(); client.userTickets.set(message.author.id, client.userTickets.size + 1); message.guild.channels.create(`t-${client.userTickets.size + 1}`, { ... });

Ejemplo para su código:

 module.exports = { name: 'new', category: 'Ticket', description: 'Creates a new ticket.', aliases: ['newticket'], usage: 'new', userperms: [], botperms: [], run: async (client, message, args) => { if(!client.userTickets) client.userTickets = new Map() if(client.userTickets.has(message.author.id)) { return message.channel.send('<@' + message.author.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-${client.userTickets.size + 1}`, { permissionOverwrites: [ { id: message.author.id, allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: "916785912267034674", allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'], }, { id: message.guild.roles.everyone, deny: ['VIEW_CHANNEL'], }, ], type: 'text', }).then(async channel => { channel.setParent('916778691672031293'); client.userTickets.set(message.author.id, client.userTickets.size + 1); message.channel.send(`<@` + message.author.id + `>, you have successfully created a ticket! Please click on ${channel} to view your ticket.`).then(m => m.delete({timeout: 3000})); channel.send(`Hi <@` + message.author.id + `>, welcome to your ticket! Please be patient, we will be with you shortly.`); const logchannel = message.guild.channels.cache.find(channel => channel.name === 'test'); if(logchannel) { logchannel.send(`Ticket-${client.userTickets.size} created. Click the following to veiw <#${channel.id}>`); } }); } }
about 4 years ago · Santiago Gelvez 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!