簡體   English   中英

在 Discord.js 上嵌入

[英]Making an embed on Discord.js

所以我正在制作一個不和諧的機器人,我希望它在我輸入hy!help時發送一個嵌入,所以我使用了 discord.js 文檔中的格式,到目前為止我的代碼看起來像這樣

const client = new Discord.Client({
    token: "pls-no-hack-ty"
});

client.on("ready", () => {
    //do stuff lol
});

client.on("message", message => {
    if(message.content === "hy!help") {
        const exampleEmbed = new Discord.MessageEmbed()
            .setColor('#0099ff')
            .setTitle('Some title')
            .setURL('https://discord.js.org/')
            .setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
            .setDescription('Some description here')
            .setThumbnail('https://i.imgur.com/wSTFkRM.png')
            .addFields(
                { name: 'Regular field title', value: 'Some value here' },
                { name: '\u200B', value: '\u200B' },
                { name: 'Inline field title', value: 'Some value here', inline: true },
                { name: 'Inline field title', value: 'Some value here', inline: true },
            )
            .addField('Inline field title', 'Some value here', true)
            .setImage('https://i.imgur.com/wSTFkRM.png')
            .setTimestamp()
            .setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
    channel.send(exampleEmbed);
        }  } )

但是我收到一個channel dot defined錯誤。

我究竟做錯了什么? 謝謝-rly907

在你的最后一行而不是channel.send(exampleEmbed);

message.channel.send(exampleEmbed);

你應該使用message.channel .send它不能使用channel.send

message.channel.send(Embed);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM