Dynamic
Dynamic
DIAdiscord.js - Imagine an app
Created by Dynamic on 3/1/2024 in #djs-questions
discord.js help
if (message.content.startsWith('hi')) {
const last_message = await message.channel.messages.fetch({ limit: 2 });
const last_embed = last_message.last().embeds[0];

let color_index = 0;
if (last_embed && last_embed.color && colors.includes(last_embed.color)) {
const last_color_index = colors.indexOf(last_embed.color);
color_index = (last_color_index + 1) % colors.length;
} else {
color_index = colors.length - 1; // Set the initial color to the last color in the array
}

const next_color_index = (color_index + 1) % colors.length;
const embed = new EmbedBuilder()
.setDescription(`Welcome to Snoopal, ${message.author}!`)
.setColor(colors[next_color_index]);
message.channel.send({ embeds: [embed] });
}
if (message.content.startsWith('hi')) {
const last_message = await message.channel.messages.fetch({ limit: 2 });
const last_embed = last_message.last().embeds[0];

let color_index = 0;
if (last_embed && last_embed.color && colors.includes(last_embed.color)) {
const last_color_index = colors.indexOf(last_embed.color);
color_index = (last_color_index + 1) % colors.length;
} else {
color_index = colors.length - 1; // Set the initial color to the last color in the array
}

const next_color_index = (color_index + 1) % colors.length;
const embed = new EmbedBuilder()
.setDescription(`Welcome to Snoopal, ${message.author}!`)
.setColor(colors[next_color_index]);
message.channel.send({ embeds: [embed] });
}
I have this array of HEX color codesand the bot is supposed to take the last embed color in the channel, find it in the array and add the next one to the new embed but all it does is the color_index keeps returning 0 so it always returns the first color code from the array
4 replies