Starting stardboard

This commit is contained in:
Patrick Hatsune 2024-05-10 15:02:01 -07:00
parent ba1ef05695
commit fbc61f65a3
2 changed files with 34 additions and 2 deletions

35
main.js
View file

@ -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);

1
star-count.json Normal file
View file

@ -0,0 +1 @@