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

214
Vistas
Can't get the total amount of invites a user did

I am trying to get the invites of the author of the command to the one server [Not multiple servers just one] I have tried many solutions but many seem outdated or wrong. Here is what I came up with

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.`);
         } )
}

This is in an invite.js file so when a user runs !invites it runs this command after exports.run

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Here's a working implementation of what you want to achieve, a few notes:

  1. A slash command called invites was created to demonstrate this functionality.
  2. If you want to test the command on your own , you can join the demo server here
  3. See attached screenshot of working forward slash command
  4. If you run the example, you will get all the invitations created
  5. If you want to filter by user ID, you need to run the slash command in Discord
Responding to a slash command Run on 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 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