Cannot Receive Direct Messages

messageCreate doesn't seem to fire when I DM the bot
const DiscordClient = new Client({ intents: ["DirectMessages", "Guilds"] })

DiscordClient.on("messageCreate", (message) => {
console.log("message")
})

DiscordClient.on("interactionCreate", (interaction) => {
console.log("interaction")
})

DiscordClient.on("ready", () => {
console.log("Logged in!")
})

DiscordClient.login(token)
const DiscordClient = new Client({ intents: ["DirectMessages", "Guilds"] })

DiscordClient.on("messageCreate", (message) => {
console.log("message")
})

DiscordClient.on("interactionCreate", (interaction) => {
console.log("interaction")
})

DiscordClient.on("ready", () => {
console.log("Logged in!")
})

DiscordClient.login(token)
3 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs2mo ago
DiscordAPIError: Cannot send messages to this user Your bot is trying to send a DM to a user, but failed to do so: - The user has DMs disabled or the bot blocked - The user no longer shares a guild with the bot (make sure to send informational DMs before banning/kicking) - The bot is trying to DM itself or another bot Note: You cannot check if you can send a DM beforehand but have to handle the rejection case Mass DMing users is not allowed as per developer ToS, considered spam and can get you and your bot banned. - Mention @everyone to inform all your users at once instead - Discord Developer Terms of Service: learn more | FAQ summary To receive direct message events on "messageCreate" with your bot, you will need: - The DirectMessages gateway intent - The Channel partial setting Bots cannot send messages in partial group dm channels. Use if ('send' in channel) or compare channel.type to mitigate this. A fix will be implemented in 14.16.2, where you can use channel.isSendable()
Sasial
SasialOP2mo ago
there we go

Did you find this page helpful?