n0tpulse-reaction-roles
v1.0.6
Published
a reaction role system for ease of use
Readme
usage:
const ReactionRoleSystem = require("n0tpulse-reaction-roles"); const reactionRole = new ReactionRoleSystem(client);
client.once("ready", async () => {
try {
// check for channel and message
const channel = await client.channels.fetch("1330721944571613226");
if (!channel) throw new Error("❌ Could not fetch channel.");
const message = await channel.messages.fetch("1341043316095058030");
if (!message) throw new Error("❌ Could not fetch message.");
console.log("✅ Message fetched successfully.");
//reaction emoji and corresponding role IDs to be added (if your emoji is custom, make sure it's uploaded to the bot)
const reactions = [
{ emoji: "emoji_1", role_id: "ROLE_ID_1" },
{ emoji: "emoji_2", role_id: "ROLE_ID_2" }
];
reactionRole.setup({
messageId: "YOUR_MESSAGE_ID",
channelId: "YOUR_CHANNEL_ID",
reactions
});
const existingReactions = message.reactions.cache.map(r => r.emoji.name);
// Add the reactions if they don't exist
for (const { emoji } of reactions) {
if (!existingReactions.includes(emoji)) {
await message.react(emoji).catch(err => {
console.error(`❌ Error adding reaction ${emoji}:`, err);
});
console.log(`✅ Added missing reaction: ${emoji}`);
} else {
console.log(`🔹 Reaction ${emoji} already exists.`);
}
}} catch (error) { console.error("❌ Error setting up reaction roles:", error); } });
