Home > Software engineering >  Mention any user on the server, displaying messages and picture discordjs
Mention any user on the server, displaying messages and picture discordjs

Time:07-21

I'm new with these bot, and I'm trying to mention user with an embed like picture. I've tried this but only sending messages and mention user, not the picture.

const { MessageAttachment } = require("discord.js");

module.exports = {
    name: 'karungin',
    description: 'this is karungin command',
    execute(message, args){
        mention = message.mentions.users.first();
        const attach = new MessageAttachment("karungin.jpg");
        
        message.channel.send(`Hello <@${mention.id}>`, {files: [attach]});
    }
};

What should I do ?

CodePudding user response:

Use an option object to send your message:

const { MessageAttachment } = require("discord.js");

module.exports = {
    name: 'karungin',
    description: 'this is karungin command',
    execute(message, args){
        mention = message.mentions.users.first();
        const attach = new MessageAttachment("karungin.jpg");
        
        message.channel.send({content: `Hello <@${mention.id}>`, files: [attach]});
    }
};

When specifying a string, only the content is taken into account.

  • Related