简体   繁体   中英

Making an embed on Discord.js

so im making a discord bot and i want it to send an embed when i type hy!help so i used the format on discord.js documantion and so far my code looks like this

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

But i get an channel dot defined error.

What am i doing wrong? Thanks -rly907

In your last line instead of channel.send(exampleEmbed); do

message.channel.send(exampleEmbed);

你应该使用message.channel .send它不能使用channel.send

message.channel.send(Embed);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM