#Embed

79 messages · Page 1 of 1 (latest)

magic pulsarBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

pseudo barn
#
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,
};
austere crag
#

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

pseudo barn
austere crag
#

do what though

#

are you having trouble creating the embed, sending the embed in the interaction reply, or both?

pseudo barn
#

like getting it to work at all because when i start the bot i get that error right away

austere crag
#

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

pseudo barn
#

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

austere crag
#

alright well what’s the error you get?

pseudo barn
#

TypeError: MessageEmbed is not a constructor

austere crag
#

Please make sure your files are saved and also double check that you don’t have any use of MessageEmbed anywhere

pseudo barn
#

like in anyother code?

austere crag
#

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

pseudo barn
#

i dont see any and i do save i have nodemon

austere crag
#

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

pseudo barn
#

oh

#

i always do C + S anyway tho

pseudo barn
# austere crag 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);
  });
};


tall ravineBOT
#

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

pseudo barn
#

what does this mean?

austere crag
#

the way you’re sending an embed is incorrect

#

needs to be an object with passing an array of embeds with the embeds option

pseudo barn
#

how would i do dat?

austere crag
#

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

pseudo barn
#

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

austere crag
#

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

tall ravineBOT
austere crag
#

there’s a wonderful guide if you’re having trouble understanding

pseudo barn
#

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


austere crag
#

looks good, try it

pseudo barn
#

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?

austere crag
#

make sure the id you put in your code is valid

tall ravineBOT
#

• 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)

pseudo barn
#

i thought to get channel id you right click the channel and hit copy id

austere crag
#

yeah that’s fine

pseudo barn
#

thats what i did than why is it incorrect

austere crag
#

I didn’t say it was incorrect

pseudo barn
#

i was reading from the /tag

#

idk if this matters but i have it like this

austere crag
#

sadly no

#

Is this a bot that you’re updating to v14? Or are you just starting out to make one

pseudo barn
#

i got this from someone im just adding on to it

#

only thing i added so far is the welcome.js

austere crag
#

are you familiar with how the code works?

pseudo barn
#

and a token and stuff

#

no

austere crag
#

that’s not very good

pseudo barn
#

i think last time i use discord.js was v11 or something

austere crag
#

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

tall ravineBOT
pseudo barn
#

okay

#

can i use older versions of discord.js still or no

austere crag
#

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

pseudo barn
#

oh

#

does slash work in v13

#

i heard thats kinda new

austere crag
#

yes, but you’re not going to have an easier time using v13 over v14

pseudo barn
#

oh okay

#

thanks for the help i might just build my own code than using the one i am using

austere crag
#

I think that’s the best thing to do

pseudo barn
#

thanks for the help

austere crag
#

You’re welcome

#

don’t hesitate to ask for more help in the help channels if you have trouble

pseudo barn
#

i wont

orchid dune