Add invite data to user joined event
As mentioned in other feedback, such as in "Track who joined what invite", knowing which invite is used can be a powerful tool for guild management. It allows for detecting the source(s) of influx of bad apples.
How would i implement this?
To enable tracking of inviters in a simple way, I would attach the user ID of the inviter to the Guild Member Add object. It is straight to the point and makes it easy to identify who invited the new user to the guild. the downside to this aproach is that it does not handle edge cases where some developers want to get more information about the invite used.
As alternative I would attach the invite object used to the Guild Member Add object. This would make it easy to read out the metadata for the invite and avoid a REST call to fetch the invite object. The downside to this aproach is that the event payload gets bloated with the less relevant information.
To avoid the bloat on the payload I would attach the invite code to the Guild Member Add object. The downside to this aproach is that it would require a REST call to GET Invite.
Bots can already provide this feature, why do we need this?
Although it is true that bots can theoretically track which invites get used, their approaches are fairly messy. They are required to internally monitor the state of the invite list and update it on each guild member added. This causes a lot of data to be sent over the wire that would barely see any use. Another downside is that in peak hours a bot might see multiple invites being used and would not able to determine which one has been used, an undesirable outcome.
Why do we need this feature sooner than later?
Discord is an evermore increasing platform for social use, with this increase in popularity and integration into the mainstream more and more bad actors have set their eyes on turning users of this platform into their victims. For example, in a guild I am in there have been multiple waves of scambots entering the guild and sending phishing links to the users. The guild had already increased the security measures to counter these bots, but they could still enter. By being able to find the account responsible for sending the invites used to harass the users the wave would've been able to be cut short and could be reported for TOS violations.
-
Hey,
This is a viable implementation. Looking at the solutions you provided, I'd opt for the last one mentioned. Associating all GuildMemberAdd (GMA) objects with an Invite Code enables more accurate tracking of invites & voids the issue where a bot has to essentially guess which GMA is associated to an invite.
Supposing you want to track invities associated with a user, you only need to GET Invite Object once. This is required to associate an inviter with their respective Invite Codes. You do not have to do a REST upon all GMA events, so I don't consider it a huge deal. Just link the inviter with the invite codes ONCE, and you're done - no excessive load:
JSON:
{
"inviter":"168056485593481216",
"invites": [
"code_one": 54,
"code_two": 3
]
}Psst... This is the appropriate GMA link- yours is broken! (https://discordapp.com/developers/docs/topics/gateway#guild-member-add).
Cheers,
Charm
1 -
Very well stated and laid out! To add to that, I'd love to see the Guild Name or ID of where that link was clicked - if it was sent via Discord and the option to block or report invites from that Guild. That won't always be an option since the invite could be from anywhere on the web, but any tools to help server admins are appreciated!
0 -
I'm thinking about building a tool that allows a bot you invite to your channel to grant roles and invite the user to channels based on the invitation link they join with
It's precise and in edge cases adds a little work to the invitee
If anyone interestedin helping me with the beta testing please reach out to me on discord (you will get a year of free access as a thank you gift)My discord id: moein#0371
0 -
Just having an inviteCode property set, even if just for GMA events, would guarantee that bots would never fail to properly identify the correct invite that is used, which also allows bots to notate who invited that user when they join - the biggest reason for tracking invites in the first place.
As it stands right now, in order to even glint an idea of who invited someone, the bot has to fetch all invites at startup (and on each restart), store them along with their counted uses and the inviter id, and then wait for a GMA event to occur, during which the bot has to refetch EVERY invite per user joining AND fetch the stored invites and hope only one invite use has occured between the GMA event being caught and the two fetch operations for comparison.
What I have experienced in a large server is that from time to time, just 2 users joining within a few milliseconds of each other can cause the bot to miss an invite usage entirely, which can throw the counts out of whack. This gets especially more convoluted when a raid occurs, where dozens, if not hundreds, of spam joins could cause all sorts of confusion with how they joined, and can cause the botcode to encounter errors due to incorrect counts on invite uses stored vs actual invite uses...not to mention what user joined with what code.
All of this disarray and lag vulnerability with missed/improperly timed/caught events is easily remedied if GMA events passed the GuildMember Object with a property of their invite code (then only a 2 column table would be needed for invite storage: invite.code and invite.inviter.id), which would never require a full guild.invites.fetch() every time a member is added.
0 -
just to highlight the current issue:
I manage and moderate a public community server of nearly 10k members, and we see almost weekly raids of anywhere from 20 - 200 spam accounts, and roughly 20% of those accounts joining have phone-verified somehow and manage to engage with the server. We see about 150 - 250 users join per week outside of raids, and most occur on Fridays. This means our in-house bot (which I maintain) has to, among other requests to the API, hit the API for upwards of 200+ invites each time a user joins.If each GMA event gave me a property of what invite code was used at that moment, I could just perform a select query on my DB for that invite code to see if it was stored, otherwise if it isn't yet (unlikely since I am listening to inviteCreate events and storing them when they are made), I only need to fetch the one invite instead of all of them (and also not have to waste tons of time trying to discover which one invite had a use in a huge for loop checking against some stored "last known" number...which has issues if the bot gets restarted).
Theoretically, my bot would never request an invite during a GMA if the invite code is known, because the bot would have done the fetchAllInvites at startup, and would add/make invites in the DB as invite events get triggered.
0
Please sign in to leave a comment.
Comments
5 comments