cannot send private message

error code
/root/discord/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/root/discord/node_modules/@discordjs/rest/dist/index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/root/discord/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async UserManager.createDM (/root/discord/node_modules/discord.js/src/managers/UserManager.js:60:18)
at async GuildMember.send (/root/discord/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:149:18) {
requestBody: { files: undefined, json: { recipient_id: '934834307258802176' } },
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/users/@me/channels'
}

Node.js v19.2.0
/root/discord/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/root/discord/node_modules/@discordjs/rest/dist/index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/root/discord/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async UserManager.createDM (/root/discord/node_modules/discord.js/src/managers/UserManager.js:60:18)
at async GuildMember.send (/root/discord/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:149:18) {
requestBody: { files: undefined, json: { recipient_id: '934834307258802176' } },
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/users/@me/channels'
}

Node.js v19.2.0
my code looks like
const channel = interaction.channel;
channel.members.forEach(member => {
try {
member.send({ embeds: [embed], components: [row] });
} catch (err) {
console.log(`Problem podczas wysyłania wiadomości do ${member.displayName}`);
console.log(err);
}
});
const channel = interaction.channel;
channel.members.forEach(member => {
try {
member.send({ embeds: [embed], components: [row] });
} catch (err) {
console.log(`Problem podczas wysyłania wiadomości do ${member.displayName}`);
console.log(err);
}
});
i tried everything but anything isn't work
6 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
wisienka
wisienkaOP2y ago
so how can i check this? there's a method? i looked at docs but i didn't search anything
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
wisienka
wisienkaOP2y ago
works ty broski 🙏🙏
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server