简体   繁体   中英

discord.py | My bot cannot send DM to other bot

I'd like to DM to a bot. This is my code.

import discord

intents = discord.Intents.default()
intents.messages = True

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')
        user = await client.fetch_user(<BotID>)
        print(user.name)
        try:
            await user.send('👀')
        except Exception as e:
            print(e)

client.run(<TOKEN>)

I got this error. "400 Bad Request (error code: 50007): Cannot send messages to this user"

Can't bot DM to other bot?

Bots cannot send messages to each other

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM