Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
Discord.js V13 404 not found

Trying to get a user id with regex, and then sending them a dm. Not working at all. The args will be like !DM @usermention.

const { MessageMentions: { USERS_PATTERN } } = require('discord.js');
const Discord = require("discord.js");
const Command = require("../Structures/Command.js");

module.exports = new Command({
    name: "DM",
    description: "Will DM given author",
    async run(message, args, client) {
        const matches = String(args).match(USERS_PATTERN);

        if (!matches) return;

        const id = matches[1];

        client.users.fetch(id).then(dm => {
            dm.send("Hello");
        })
    }
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are converting the array to a string before matching, which should work fine but I'm not sure it's what you want.

Then you are getting the second match with matches[1] instead of the first one.

And then you are using the match, formatted as <@XXXXXXXX> as an id, which is supposed to be numerical.

I would suggest replacing all that with simply:

async run(message, args, client) {
    message.mentions.users.first().send('Hello');
}

this gets the first user mention in the message and dms the user 'Hello'

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda