Detecting Multiple Guild IDs –

  discord,, python, python-3.x

This code works for sending a DM to a user who joined a guild, but it only executes the first if statement instead of actually checking to see what guild the member joined. I’ll get the first DM from the bot whether I join guild1 or guild2.

async def on_member_join(member):
    guild1 = client.get_guild(762921541204705321)
    guild2 = client.get_guild(593941391110045697)
    if == 762921541204705321:
        await member.create_dm()
        await member.dm_channel.send("Welcome to guild1!")
    elif == 593941391110045697:
        await member.create_dm()
        await member.dm_channel.send(f"Welcome to guild2!")

Source: Python Questions