diff --git a/main.js b/main.js index 9ee1f80..7f3d5ac 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -const { Client, Collection, Events, GatewayIntentBits } = require('discord.js'); +const { Client, Collection, Events, EmbedBuilder, GatewayIntentBits, Partials } = require('discord.js'); const { token } = require('./config.json'); const fs = require('node:fs'); const path = require('node:path'); @@ -7,7 +7,12 @@ const informationStatus = "[INFO]: "; const warningStatus = "[WARNING]: "; const errorStatus = "[ERROR]: "; -const client = new Client({ intents: [GatewayIntentBits.Guilds] }); +const starChannelID = "1211566862148567091"; + +const client = new Client({ + intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions], + partials: [Partials.Message, Partials.Channel, Partials.Reaction], +}); client.commands = new Collection(); @@ -70,4 +75,30 @@ client.on(Events.InteractionCreate, async interaction => { } }); +client.on(Events.MessageReactionAdd, async (reaction, user) => { + if (reaction.partial) { + try { + await reaction.fetch(); + + const starChannel = client.channels.cache.get(starChannelID); + + starChannel.send(reaction.message.attachments); + + if (reaction.emoji.name == '⭐') { + const starEmbed = new EmbedBuilder() + //.setImage() + .setDescription(reaction.message.content) + .setAuthor({ name: `${reaction.message.author.tag}` }); + starChannel.send({ embeds: [starEmbed] }); + } else { + return; + } + } catch (error) { + console.log(errorStatus + 'Something wrong happend while fetching reactions for message! Please use information below to debug.'); + console.error(error); + }} + } +); + + client.login(token); diff --git a/star-count.json b/star-count.json new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/star-count.json @@ -0,0 +1 @@ +