I look for the embed of the code that I have passed to be sent in the first available channel every time the bot enters a server.
This would be the code snippet.
const { Client, GatewayIntent`your text`Bits, MessageEmbed } = require('discord.js');
const config = require('./config.json');
const { EmbedBuilder } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent
]
});
const prefix = config.prefix;
client.on('ready', () => {
console.log('Bot Ready');
});
client.on('messageCreate', message => {
if (message.content === '!ping') {
message.channel.send('pong');
}
});
client.on('guildCreate', guild => {
const channel = guild.channels.cache.find(channel => channel.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'));
if (channel) {
const exampleEmbed = new MessageEmbed()
.setColor(0xF99CF8)
.setTitle('**B**')
.setAuthor('S')
.setThumbnail('https://i.imgur.com/N4')
.setDescription('H')
channel.send({ embeds: [exampleEmbed] });
}
});
client.login(config.token);
As a result of this code, the bot does not send any type of message when entering servers, but starts normally.
2
Answers
if you are using discord.js v14 then you will need to update your way in replying with Embeds
Just change to this code :
Also you will need to edit the first line to :
just remove the third line to make your code cleaner
For more details you can go here :
https://discordjs.guide/popular-topics/embeds.html#embed-preview
In
discord.js
v14,enum
s.<Guild>.me
was replaced by<Guild>.members.me
.Read more about breaking changes in
v14
here.