#Embed
79 messages · Page 1 of 1 (latest)
[email protected] deduped
└── [email protected]
const { EmbedBuilder } = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
const data = new SlashCommandBuilder()
.setName('help')
.setDescription("helpcommands");
module.exports.execute = async (client, interaction) => {
return interaction.reply(``)
};
module.exports.options = {
...data.toJSON()
};
module.exports.config = {
enabled: true,
};
you should export everything directly from discord.js since @discordjs/builders and discord-api-types is included so there really isn’t a need to do two separate imports in v14
On another note, I don’t see where you want to use an embed or any code that resembles where the error is originating from
i removed the code for how cuz of the error but i wanted to do it were return interaction.reply(``) is
do what though
are you having trouble creating the embed, sending the embed in the interaction reply, or both?
like getting it to work at all because when i start the bot i get that error right away
you still didn’t provide the code where the error comes from, but MessageEmbed has been renamed to EmbedBuilder in v14
if you don’t have MessageEmbed anywhere in your code and you still receive the error, make sure your files are saved
there’s only so much I can do to help with the information that is given
this is the code i use before
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle('Some title')
.setURL('https://discord.js.org/')
module.exports.config = {
enabled: true,
};
alright well what’s the error you get?
TypeError: MessageEmbed is not a constructor
Please make sure your files are saved and also double check that you don’t have any use of MessageEmbed anywhere
like in anyother code?
you should search your entire code base
if you dont find anything with MessageEmbed, again please make sure your files are saved
There’s really nothing more I can suggest
i dont see any and i do save i have nodemon
that’s just a package
CTRL + S
nodemon doesn’t save your files btw
It just restarts the node app when the file has changes
so like this welcome code it doesnt send anything when someone joins but i no longer got the error just no message pops up
const Discord = require('discord.js');
module.exports = client => {
client.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.get('1071533510420582473');
if (!channel) return;
const embed = new Discord.EmbedBuilder()
.setColor('#00FF00')
.setTitle(`Welcome to the server, ${member.user.tag}!`)
.setDescription('We are glad to have you here!')
.setImage('https://media.discordapp.net/attachments/1040617924492263434/1093381788707070083/blue_lion_pfp.gif');
channel.send(embed)
.then(console.log(`Sent welcome message to ${member.displayName}`))
.catch(console.error);
});
};
Sending and editing now takes only a single object parameter!
- channel.send(embed);
+ channel.send({ embeds: [embed, embed2] });
- channel.send('Hello!', { embed });
+ channel.send({ content: 'Hello!', embeds: [embed, embed2] });
• V12-v13 migration guide: learn more
• V13-v14 migration guide: learn more
what does this mean?
the way you’re sending an embed is incorrect
needs to be an object with passing an array of embeds with the embeds option
how would i do dat?
look at the tag I sent
- means you remove that
+ is what you change it to with taking your code into account since the tag is just an example of what the correct format is suppose to follow
okay? i think i understand
so
i remove channel.send(embed)
and make it something like this?
channel.send({ content: 'Hello!', embeds: [embed, embed2] });
.then(console.log(`Sent welcome message to ${member.displayName}`))
.catch(console.error);
sorry if im asking really dumb questions havnt touch discord.js in years and never did embeds before
you can, but you don’t have 2 embeds. Only 1. Also, you have if(!channel) return; which means basically if the channel isn’t found, your code is not going to do anything so make sure that channel id is correct
there’s a wonderful guide if you’re having trouble understanding
so
const embed = new Discord.EmbedBuilder()
.setColor('#00FF00')
.setTitle(`Welcome to the server, ${member.user.tag}!`)
.setDescription('We are glad to have you here!')
.setImage('https://media.discordapp.net/attachments/1040617924492263434/1093381788707070083/blue_lion_pfp.gif');
channel.send({ content: 'Hello!', embeds: [embed] });
.then(console.log(`Sent welcome message to ${member.displayName}`))
.catch(console.error);
});
};
looks good, try it
okay thank you
okay so no errors besides the . in (.)then(console.log(`Sent welcome message to but besides that nothing sent in the server and the id is right now i have it in. welcome.js my guess i have to do something in index.js?
make sure the id you put in your code is valid
• The provided id is incorrect (copy role ids from context menus, not message mentions)
• The client does not have this structure cached (try fetching instead)
• The client is not yet ready (move the code into any event listener callback)
i thought to get channel id you right click the channel and hit copy id
yeah that’s fine
thats what i did than why is it incorrect
I didn’t say it was incorrect
sadly no
Is this a bot that you’re updating to v14? Or are you just starting out to make one
i got this from someone im just adding on to it
only thing i added so far is the welcome.js
are you familiar with how the code works?
that’s not very good
i think last time i use discord.js was v11 or something
It’s hard for us to help if even you don’t understand how the code functions. I suggest looking at the guide fully, especially the event and command handling section
Creating Your Bot: Event handling
read more
Creating Your Bot: Command handling
read more
anything below v13 we don’t support and I don’t recommend doing so anyway since they will have unknown errors that are not fixed in newer api versions
yes, but you’re not going to have an easier time using v13 over v14
oh okay
thanks for the help i might just build my own code than using the one i am using
I think that’s the best thing to do
thanks for the help
You’re welcome
don’t hesitate to ask for more help in the help channels if you have trouble
i wont