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

210
Views
No se puede obtener la cantidad total de invitaciones que hizo un usuario

Estoy tratando de obtener las invitaciones del autor del comando para un servidor [no varios servidores, solo uno]. He probado muchas soluciones, pero muchas parecen obsoletas o incorrectas. Esto es lo que se me ocurrió

 exports.run = async (client, message, args) => { var user = message.author; message.guild.invites.fetch() .then(invites => { const userInvites = invites.filter(o => o.inviter.id === user.id); var userInviteCount = 0; console.log(userInvites['uses']); for (var i=0; i < userInvites.length; i++) { var invite = userInvites[i]; userInviteCount += invite['uses']; } message.reply(`You have ${userInviteCount} invites.`); } ) }

Esto está en un archivo invite.js, por lo que cuando un usuario ejecuta !invites, ejecuta este comando después de export.run

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Aquí hay una implementación funcional de lo que desea lograr, algunas notas:

  1. Se creó un comando Slash llamado invites para demostrar esta funcionalidad.
  2. Si desea probar el comando por su cuenta , puede unirse al servidor de demostración aquí
  3. Ver captura de pantalla adjunta del comando de barra diagonal de trabajo
  4. Si ejecuta el ejemplo, obtendrá todas las invitaciones creadas
  5. Si desea filtrar por ID de usuario, debe ejecutar el comando de barra en Discord
Respondiendo a un comando de barra Ejecutar en Fusebit
 // Respond to a Slash command integration.event.on('/:componentName/webhook/:eventType', async (ctx) => { const { data: { application_id, token, member }, } = ctx.req.body; // Store the user id that triggered the bot command. const commandTriggeredByUser = member.user.id; const discordClient = await integration.service.getSdk(ctx, connectorName, ctx.req.body.installIds[0]); const guildInvites = await discordClient.bot.get(`guilds/${DISCORD_DEMO_GUILD_ID}/invites`); // Filter the user created invites only const userCreatedInvites = guildInvites.filter(invite => invite.inviter.id === commandTriggeredByUser); // Reply to the slash command with the number of created invites await superagent.post(`https://discord.com/api/v8/webhooks/${application_id}/${token}`).send({ content: `You have created ${userCreatedInvites.length} invites`, }); });
over 4 years ago · Santiago Trujillo 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!