Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda