client.on(Events.MessageReactionAdd, async (reaction, err) => { if (reaction.emoji.name === '⭐') { try { await reaction.fetch(); } catch (error) { console.log(error) } const stardata = await starschema.findOne({ Guild: reaction.message.guild.id }); const reactions = reaction.message.reactions.cache.get('⭐').count; const messagedata = await starmessageschema.findOne({ Message: reaction.message.id }) if (messagedata) { const reactmessage = await client.channels.cache.get(messagedata.Channel).messages.fetch(messagedata.Reaction); const newreactions = reactions; const receivedEmbed = await reactmessage.embeds[0]; try { const newembed = EmbedBuilder.from(receivedEmbed).setFields({ name: `Stars`, value: `> ${newreactions} ⭐`}); reactmessage.edit({ embeds: [newembed]}).catch(err); } catch (err) { console.log(err) } } const id = reaction.message.id; if (!stardata) return; if (reactions > stardata.Count) { if (reaction.message.channel.id === stardata.Channel) return; if (stardata.SentMessages.includes(id)) return; if (stardata.BanUser.includes(reaction.message.author.id)) return; const starembed = new EmbedBuilder() .setColor('Yellow') .setThumbnail(reaction.message.guild.iconURL()) .setTimestamp() .setAuthor({ name: `⭐ Starred Message`}) .setTitle(`Message by: ${reaction.message.author.tag}`) .setDescription(`${reaction.message.content || 'No message given.'}`) .setFooter({ text: `Stars: ${reactions} ⭐`}) if (reaction.message.attachments.size > 0) { try { starembed.setImage(`${reaction.message.attachments.first()?.url}`); } catch (err) { console.log(err) } } const starchannel = await reaction.message.guild.channels.cache.get(stardata.Channel); const starmsg = await starchannel.send({ embeds: [starembed] }).catch(err); await starmessageschema.create({ Reaction: starmsg.id, Message: reaction.message.id, Channel: stardata.Channel }) try { starmsg.react('⭐'); } catch (err) { console.log(err) } await starschema.updateOne({ Guild: reaction.message.guild.id }, { $push: { SentMessages: id }}); } } }) client.on(Events.MessageReactionRemove, async (reaction, err) => { if (reaction.guild === 'null') return; if (reaction.emoji.name === '⭐') { try { await reaction.fetch(); } catch (error) { console.log(error) } const stardata = await starschema.findOne({ Guild: reaction.message.guild.id }); const reactions = reaction.message.reactions.cache.get('⭐').count; const messagedata = await starmessageschema.findOne({ Message: reaction.message.id }) if (messagedata) { const reactmessage = await client.channels.cache.get(messagedata.Channel).messages.fetch(messagedata.Reaction); const newreactions = reactions; const receivedEmbed = await reactmessage.embeds[0]; if (reactions < stardata.Count) { try { const newembed1 = EmbedBuilder.from(receivedEmbed).setFields({ name: `Stars`, value: `> Not enough ⭐`}); reactmessage.edit({ embeds: [newembed1]}).catch(err); } catch (err) { console.log(err) } } else { try { const newembed2 = EmbedBuilder.from(receivedEmbed).setFields({ name: `Stars`, value: `> ${newreactions} ⭐`}); reactmessage.edit({ embeds: [newembed2]}).catch(err); } catch (err) { console.log(err) } } } } })