【问题标题】:Mention any user on the server, displaying messages and picture discordjs提及服务器上的任何用户,显示消息和图片 discordjs
【发布时间】:2022-07-21 16:51:51
【问题描述】:

我是这些机器人的新手,我试图通过嵌入图片来提及用户。我已经尝试过了,但只发送消息和提及用户,而不是图片。

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]});
    }
};

我该怎么办?

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    使用选项对象发送消息:

    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]});
        }
    };
    

    指定字符串时,仅考虑内容。

    【讨论】:

      猜你喜欢
      • 2017-09-30
      • 2020-01-10
      • 2011-12-07
      • 1970-01-01
      • 2018-03-03
      • 2019-08-12
      • 2021-09-04
      • 2016-05-11
      • 2013-01-02
      相关资源
      最近更新 更多