Can Discord bots send private messages to each other?

I’m working on a project where I need my test bot to check the commands of my primary bot. Everything’s going smoothly except for one issue. The test bot can’t seem to get DMs from the main bot.

I’m using discord.js and tried this code:

userToMessage.send('Hey there! Testing bot-to-bot DMs')

But I keep getting this error:

Error: Unable to send direct message to this user

Is there a way to make this work? Maybe a special setting or a trick to let bots message each other privately?

Both bots can get DMs from regular users without any problems. It’s just the bot-to-bot messaging that’s not working. Any ideas on how to fix this?

From my experience, Discord bots can’t directly DM each other. It’s a security measure implemented by Discord to prevent potential abuse. Instead, consider creating a private channel on your server that only your bots have access to. This way, they can exchange messages without involving other users. Alternatively, you could set up an external API or database for inter-bot communication. These methods have worked well for me in similar projects. Remember to always respect Discord’s rate limits and terms of service when implementing any solution.

i dont think bots can dm each other directly. thats probably a discord limitation to prevent spam or something. maybe try using a server channel only the bots can access? or use an api endpoint to communicate between em. just brainstorming here, hope it helps!

As someone who’s spent countless hours tinkering with Discord bots, I can confirm that direct bot-to-bot messaging isn’t possible. It’s a deliberate restriction by Discord to prevent potential abuse.

However, there’s a workaround that’s served me well. Create a private channel on your server and give both bots access to it. They can then communicate freely there without bothering other users. Just remember to set the permissions correctly so no one else can peek in.

Another option I’ve used is setting up a simple web server that both bots can ping. This allows for more complex interactions and data sharing between your bots. It’s a bit more work to set up, but it offers a lot more flexibility in the long run.

Whatever method you choose, make sure to implement proper error handling and respect Discord’s rate limits. Good luck with your project!