how can I send message to a removed member in discord.py?

I want to send messages to a removed member, but I can't find the solutions. I used member.send and user.send. But it isn't working.

await member.sned_request_friend()

I try to use this, but this is not working. I think because of it is a bot, not a client.

2 answers

  • answered 2020-07-10 14:05 Lu M

    Discord Bots can only message people with which they are in a server with. (this is a rule of thumb, in theory a bot may still have some users cached, but if it does not work, this will most likely be the reason)

    If the member is removed from the server, but still in another server with the bot, you have to refetch them by ID, like so

    import discord
    
    id_of_user = 1234
    user = discord.utils(client.users, id=id_of_user)
    

    Using client.users which returns a list of all users the client can see and discord.utils.get to find the user with the correct id.

  • answered 2020-07-11 09:38 FluxedScript

    If you want to contact them if they get banned make sure to send the message before banning the user. Since this is a discord security feature so bots cannot dm advertise something to all of discord's users.

    Maybe you thought of all the people joining and leaving your server after a few minutes, they are just self bots or people who don't really want to be in your server.