My embed doenst work #embeds

my embeds dont send, but messages usually do. I tried to change the code and looked for help with gpt but emebed still doesnt work /:
const Discord = require('discord.js');
const fs = require('fs');

const client = new Discord.Client({ intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent
]});

client.commands = new Discord.Collection();

const commandfolders = fs.readdirSync('./commands');

for (const folder of commandfolders) {
const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('js'));

for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}

const prefix = '!';

client.once('ready', () => {
console.log(`Logged in as ${client.user.tag} (bot is online)`);
client.user.setActivity('wacuus', { type: 'WATCHING' });
});

client.on('messageCreate', async message => {
console.log(`Message received: ${message.content}`); // Logging the message

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

console.log(`Command detected: ${commandName}`); // Logging the command name

if (!client.commands.has(commandName)) {
console.log(`Command not found: ${commandName}`); // If the command doesn't exist
return;
}

const command = client.commands.get(commandName);

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Oops... Something went wrong, and your command could not be executed.');
}

console.log('Loaded commands:');
client.commands.forEach((command, name) => {
console.log(`- ${name}`);
});
});

client.login('YOUR_BOT_TOKEN');
const Discord = require('discord.js');
const fs = require('fs');

const client = new Discord.Client({ intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent
]});

client.commands = new Discord.Collection();

const commandfolders = fs.readdirSync('./commands');

for (const folder of commandfolders) {
const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('js'));

for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}

const prefix = '!';

client.once('ready', () => {
console.log(`Logged in as ${client.user.tag} (bot is online)`);
client.user.setActivity('wacuus', { type: 'WATCHING' });
});

client.on('messageCreate', async message => {
console.log(`Message received: ${message.content}`); // Logging the message

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();

console.log(`Command detected: ${commandName}`); // Logging the command name

if (!client.commands.has(commandName)) {
console.log(`Command not found: ${commandName}`); // If the command doesn't exist
return;
}

const command = client.commands.get(commandName);

try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('Oops... Something went wrong, and your command could not be executed.');
}

console.log('Loaded commands:');
client.commands.forEach((command, name) => {
console.log(`- ${name}`);
});
});

client.login('YOUR_BOT_TOKEN');
Version: v22.12.0
10 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
wacuus
wacuusOP3w ago
Embed file:
const { EmbedBuilder } = require('discord.js');

module.exports = {
name: 'embed_regulamin',
description: "Regulamin Serwera",
usage: '!embed',
execute: async (message, args) => {
const embed_regulamin = new EmbedBuilder()
.setTitle('Regulamin serwera svcut.pl')
.setDescription('Przykładowy regulamin')
.setColor(0x00AE86);

message.channel.send({ embeds: [embed_regulamin] });
},
};
const { EmbedBuilder } = require('discord.js');

module.exports = {
name: 'embed_regulamin',
description: "Regulamin Serwera",
usage: '!embed',
execute: async (message, args) => {
const embed_regulamin = new EmbedBuilder()
.setTitle('Regulamin serwera svcut.pl')
.setDescription('Przykładowy regulamin')
.setColor(0x00AE86);

message.channel.send({ embeds: [embed_regulamin] });
},
};
Mark
Mark3w ago
What happens when you try to send an embed? Do you get an error in the terminal?
treble/luna
treble/luna3w ago
also what is your djs version because some of that code is outdated which chatgpt and ai tend to do so dont use ai
Mark
Mark3w ago
Please update to v14 We do not offer support for older versions, including v12
wacuus
wacuusOP3w ago
i have just installed to v14 and restared pc, and im tottally new in discord.js so imsry
d.js docs
d.js docs3w ago
:guide: Home: What's new read more
treble/luna
treble/luna3w ago
follow the guide not some ai
wacuus
wacuusOP3w ago
The problem has been solved. If someone has the same issue, in the export module, name must be the same as in usage. You need to emphasize that because they are variables. So if in name you had embedRegulamin and in usage you had embed, then name must also be exactly embed, as should the file name.

Did you find this page helpful?