How to make an invite logger in discord.py?

374 Views Asked by At

So basically I am not requesting a code or something , I just want to know how invite loggers are made , basically by an invite logger I mean that I want to get the invite link , who was invited , invited by who , time of invite (I can do this one). So I want to know which attribute / command should I use to get the above details except time of invite. Your help will be really appreciated.

I did some searching in docs and found that on_invite_create(invite) , but according to docs it is called when an invite is created and not when it is used , hope someone can help me with it.

1

There are 1 best solutions below

0
FierySpectre On BEST ANSWER

The on_member_join() event does indeed not have a referrer, but you can manually find out by checking the invite list of the guild whenever a member joins.

A guild object has a coroutine called guild.invites() which returns a list of Invite objects. These contain all information about an invite, by iterating over that list you can find out which invite changed when the member joined, thus you know:

  • link with invite.url (or invite.code for just the letter code)
  • inviter with invite.inviter
  • Number of users they have invited (with that link) with invite.uses