Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

discord.js - Discord.Message.Embed is not a constructor

so i tried making an embed. this is the code for it

const Discord = require('discord.js')

//example (inside of a command)

const embed = new Discord.messageEmbed()
embed.setAuthor(`Phaze Bot`)
embed.setTitle(`Commands List`)
embed.setDescription(`$kick: kicks a member 
 $ban: bans a member 
 $help music: displays music commands 
 $help: displays the help screen`)

message.channel.send({embed});

Update so now i got that working, but the bottom line of the code sends

Blockquote ReferenceError: message is not defined

i now need a fix on this if anyone can help


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Put the function inside a on event:

const Discord = require('discord.js')
const client = new Discord.Client();

client.on("message", (message) => {
   const embed = new Discord.messageEmbed()
   embed.setAuthor(`Phaze Bot`)
   embed.setTitle(`Commands List`)
   embed.setDescription(`$kick: kicks a member 
 $ban: bans a member 
 $help music: 
   displays music commands 
 $help: displays the help screen`)
   
   message.channel.send(embed);
})

If you want to send the message to specific channel as you mentioned, you would want to use something like this:

client.channels.cache.get(CHANNEL_ID).send(embed)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...