So i made a simple command for dming users that are in the same server as the bot time ago, and it always worked fine, but it is giving this error now for some reason:
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown User
at RequestHandler.execute (C:\Users\Name\Documents\GitHub\bbq-bot\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Name\Documents\GitHub\bbq-bot\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async UserManager.fetch (C:\Users\Name\Documents\GitHub\bbq-bot\node_modules\discord.js\src\managers\UserManager.js:69:18) {
method: 'get',
path: '/users/12345',
code: 10013,
httpStatus: 404,
requestData: { json: undefined, files: [] }
}
Code here:
module.exports = {
name: 'dm',
description: 'dms a user',
async execute(message, args, client, config) {
// Variables and Conditions
const dmToSend = args.slice(1).join(" ");
const attachmentToSend = message.attachments.map(att => att.url);
if (message.author.id !== config.ownerid)
return message.channel.send("This command is for the bot owner only")
if (!args[0]) return message.channel.send("Please put a user id")
if (message.attachments.size == 0) {
client.users.fetch(args[0]).then((user) => {
user.send({ content: dmToSend })
})
} if (message.attachments.size !== 0) {
client.users.fetch(args[0]).then((user) => {
user.send({ content: dmToSend + attachmentToSend })
})
}
}
}
It always worked fine as i said, and i don't understand what is happening, i think is because of the changes in the client const in djs v13, in case that's the problem here's my intents:
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES"], partials: ["CHANNEL"] });