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");
        })
    }
})```

Source: JavaSript – Stack Overflow

November 28, 2021
Category : News
Tags: discord | discord.js | javascript | node.js

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.