const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
]
});
const yourUserID = '';
const specificBotID = '';
let cooldown = false;
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('messageCreate', (message) => {
if (message.author.id === specificBotID) {
// Check if the message is from the specific bot
if (!cooldown) {
// If the bot is not on cooldown, tag and set the cooldown
console.log('Received message:', message);
// Check if the message has embeds
if (message.embeds.length > 0) {
const embed = message.embeds[0];
const embedColor = embed.hexColor || embed.color;
if (embedColor) {
// Sending the message with the hex color included
message.channel.send(`<@${yourUserID}> The specific bot sent a message. The embed color is ${embedColor}.`);
} else {
message.channel.send(`<@${yourUserID}> The specific bot sent a message. The embed color is not available.`);
}
} else {
message.channel.send(`<@${yourUserID}> The specific bot sent a message, but no embeds were found.`);
}
cooldown = true;
// Set a 2-second cooldown
setTimeout(() => {
cooldown = false;
}, 2000);
}
}
});
I am trying to make a discord bot that detects if an embed is sent and sends a message containing the colour Stripe of the embed. But it is not detecting an embed at all as I printed the message info and the embed array was empty. Could anyone take a look and lmk whats wrong
You need the Message Content intent (and therefore, MessageContent in your intents code) in order to see the embeds or content objects for messages the bot doesn't own. Note that you'll have to toggle this in the developer portal.