特征?,javascript,discord.js,command"/>

首页 > 解决方案 > 我将如何修复嵌入命令中的意外标记/添加特征?

问题描述

我正在编写一个小机器人项目,为了挑战自己,我决定编写一个新命令。该命令应该进行嵌入,并且在该嵌入中,[提及目标用户和使用该命令的人],[嵌入短视频]

module.exports = {
    name: "bonk",
    description: "bonks someone",
    category: "funsies",
    command: true,
    execute(message, args, Discord) {
        const bonkEmbed = new Discord.MessageEmbed()
            .setColor("#cc4371")
            .setTitle("<@user> BONKED <@target user>")
            .setDescription("[somethin, idfk]")
            .setThumbnail("https://discord.com/channels/774446440252309524/881660577351630849/887115025775476747")
            .addFields({ name: "you got bonked!", value: "https://discord.com/channels/774446440252309524/881660577351630849/887110690719010847" }),
            .setTimestamp()
            .setFooter('~~lmao~~');


            message.channel.send(bonkEmbed);

        }
    }; 
module.exports = {
    name: 'impostor',
    description: 'Calls someone an impostor.',
    category: 'funsies',
    command: true,
    execute(message, args) {
        const user = message.mentions.users.first() || message.author;
        var receiver = "<@!" + user + ">";
        message.channel.send(receiver + " was the impostor", {
            files: ['https://media.discordapp.net/attachments/716942890089316383/755907669453438996/among_us_lmao.png?width=356&height=475']
        });
    },
};

由于我对javascript缺乏经验,我将这两个代码中的后者用作前者的一种脚手架。我使用了一种已经存在的嵌入格式,但这给我在命令提示符下带来了问题。它不希望某些对于此命令起作用必不可少的令牌,而且我不知道如何修复它们。

标签: javascriptdiscord.jscommand

解决方案


您无法在嵌入标题中添加提及,请尝试在描述中使用提及

顺便说一句,它不会提及用户,它就像一个文本......

此外,您正在将消息链接设置为缩略图和字段!


推荐阅读