DiscordUtils.invitetracker


Module Contents

Classes

InviteTracker

A usefull class to track invites of member whenever a user is invited to a guild.

class DiscordUtils.invitetracker.InviteTracker(bot)[source]

A usefull class to track invites of member whenever a user is invited to a guild.

Parameters

bot (Union[Client, AutoShardedClient, Bot, AutoSharededBot]) –

Attributes
  • bot: The default bot class.

  • _cache: dict

    A dict to cache Guild instances Invite

__slots__ = ['bot', '_cache']
add_listeners(self)[source]

It adds the following listeners to the Bot instance.

Mapping

Function

Discord Function

cache_invites()

on_ready()

update_invite_cache()

on_invite_create()

remove_invite_cache()

on_invite_delete()

add_guild_cache()

on_guild_join()

remove_guild_cache()

on_guild_remove()

Return type

None

await cache_invites(self)[source]

It cache the guild invites automatically whenever the on_ready() event is fired

Return type

None

await update_invite_cache(self, invite)[source]

It updates the invite cache automatically whenever the on_invite_create() event is fired

Parameters

invite (discord.invite.Invite) –

Return type

None

await remove_invite_cache(self, invite)[source]

It removes the invite cache of the deleted invite automatically whenever the on_invite_delete() event is fired

Parameters

invite (discord.invite.Invite) –

await add_guild_cache(self, guild)[source]

It adds the guild to cache automatically whenever the on_guild_join() event is fired

Parameters

guild (discord.guild.Guild) –

Return type

None

await remove_guild_cache(self, guild)[source]

It removes the guild from cache automatically whenever the on_guild_remove() event is fired

Parameters

guild (discord.guild.Guild) –

Return type

None

await fetch_inviter(self, member)[source]

This utility function returns the Invite class which was used when the member joined the guild.

Parameters

member (discord.Member) – The member which joined the guild. (The Member recieved during on_member_join() event)

Returns

If the member was bot i.e. invited via integration then it would return None

Return type

Optional[discord.Invite]