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

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

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 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