Invite Tracker
Initializing Invite Tracker
tracker = PycordUtils.InviteTracker(bot)
Once you have the above code ready,
@bot.event
async def on_member_join(member):
inviter = await tracker.fetch_inviter(member) # inviter is the member who invited
Example Cog
Invites.py
import PycordUtils
from discord.ext import commands
class Invite(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.tracker = PycordUtils.InviteTracker(bot)
@commands.Cog.listener()
async def on_ready(self):
await self.tracker.cache_invites()
@commands.Cog.listener()
async def on_invite_create(self, invite):
await self.tracker.update_invite_cache(invite)
@commands.Cog.listener()
async def on_guild_join(self, guild):
await self.tracker.add_guild_cache(guild)
@commands.Cog.listener()
async def on_invite_delete(self, invite):
await self.tracker.remove_invite_cache(invite)
@commands.Cog.listener()
async def on_guild_remove(self, guild):
await self.tracker.remove_guild_cache(guild)
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member) -> None:
# inviter is the member who invited
if member.bot:
return
inviter = await self.tracker.fetch_inviter(member)
Last updated