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

216
Views
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 answers
Answer question

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