Lysander12 PT
Lysander12 PT

Reputation: 164

Get person who invited the discord bot discord.py

Is there any way to get the person who invited the bot to the server? My point is to dm that person to tell her what to do so things go smoothly and I don't want the bot to just write it in a random text channel that everybody could see. Thanks in advance

Upvotes: 1

Views: 336

Answers (2)

south
south

Reputation: 11

there is an actual way to get the user who invited the bot

    @commands.Cog.listener() 
    async def on_guild_join(self, guild: discord.Guild):
     async for entry in guild.audit_logs(limit=1, action=discord.AuditLogAction.bot_add):
      mem = entry.user
      if entry.target.id == self.bot.user.id:
        await mem.send("thank you for inviting me")

you can do it by checking the audit log

Upvotes: 1

Just for fun
Just for fun

Reputation: 4225

There isn't any way yet to know who invited the bot. What you can do is DM the Server Owner when its added to a Server.

Upvotes: 1

Related Questions