This is the gacha function i used:
if (command === ‘!gacha’) {
const now = Date.now();
if (cooldowns.has(userId) && now - cooldowns.get(userId) < 5 * 60 * 1000) {
await message.channel.send("You must wait 5 minutes between gacha pulls.");
return;
}
cooldowns.set(userId, now);
try {
const { character, rarity, imagePath, imageIndex } = await getRandomCharacter();
// Check if the image file exists
if (!fs.existsSync(imagePath)) {
await message.channel.send("The image file for the gacha result was not found.");
return;
}
const dropId = await insertDrop(userId, character.id, imageIndex, rarity, new Date().toISOString());
const embed = new EmbedBuilder()
.setTitle(`You drew: ${character.name} (${rarity})!`)
.setDescription(`Drop ID: ${dropId}`)
.setImage('attachment://' + path.basename(imagePath))
.setColor({
'Common': '#A0A0A0',
'Uncommon': '#00FF00',
'Rare': '#0000FF',
'Epic': '#800080',
'Legendary': '#FFD700',
'Mythic': '#FF0000',
'Exotic': '#FF69B4'
}[rarity] || '#FFFFFF');
await message.channel.send({ files: [imagePath], embeds: });
} catch (error) {
console.error("Error processing gacha pull:", error.message);
await message.channel.send("An error occurred while processing your gacha pull.");
Even tho it doesnt show any error, the bit reais it without a problem and then adds the card to the inventory it doesnt send the card Im chat even tho its suposed to.
I tried changing image paths thinking it prob was that but still not working used URLs instead of local images and still nothing i think its not a imagem problem since the “view” comando shows them without any errors
alt 2 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.