npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-reaction-role

v2.1.0

Published

[![downloadsBadge](https://img.shields.io/npm/dt/discord-reaction-role?style=for-the-badge)](https://npmjs.com/discord-reaction-role) [![versionBadge](https://img.shields.io/npm/v/discord-reaction-role?style=for-the-badge)](https://npmjs.com/discord-reac

Downloads

193

Readme

Discord Reaction Role

downloadsBadge versionBadge

Discord Reaction Role is a powerful Node.js module that allows you to easily create reactions roles !

Installation

npm i discord-reaction-role

Exemple

Lunch of the module

const Discord = require("discord.js"),
client = new Discord.Client(),
settings = {
    prefix: "r!",
    token: "Your Discord Token"
};

// Requires Manager from discord-reaction-role
const ReactionRoleManager = require("discord-reaction-role");
// Starts updating currents reaction roles
const manager = new ReactionRoleManager(client, {
    storage: "./reaction-role.json"
});
// We now have a reactionRoleManager property to access the manager everywhere!
client.reactionRoleManager = manager;

client.on("ready", () => {
    console.log("I'm ready !");
});

client.login(settings.token);
  • client: the discord client (your discord bot instance)
  • options.storage: the json file that will be used to store reaction roles

Start

client.reactionRoleManager.create({
      messageID: '706857963188387903',
      channel: message.channel,
      reaction: '✅',
      role: message.guild.roles.cache.get('675995543062839306')
})

Delete

client.reactionRoleManager.delete({
          messageID: "707532556223905802",
          reaction: "✅",
        });

Fetch the reaction role

    // The list of all the reaction roles
    let allReactionRoles = client.reactionRoleManager.reactionRole; // [ {ReactionRole}, {ReactionRole} ]

    let onServer = client.reactionRoleManager.reactionRole.filter((rr) => rr.guildID === "1909282092");

Events

reactionRoleAdded

client.reactionRoleManager.on('reactionRoleAdded',(reactionRole,member,role,reaction) => {
  console.log(`${member.user.username} added his reaction \`${reaction}\` and won the role : ${role.name}`);
})

reactionRoleRemoved

client.reactionRoleManager.on("reactionRoleRemoved", (reactionRole, member, role, reaction) => {
  console.log(`${member.user.username} removed his reaction \`${reaction}\` and lost the role : ${role.name}`)
});

Custom database

An example with quick.db

const Discord = require('discord.js');
const ReactionRolesManager = require("./index");
const client = new Discord.Client();

const settings = {
  prefix: 'r!',
  token: 'Your bot token'
};

const db = require("quick.db");
if (!db.get("reaction-role")) db.set("reaction-role", []);

const reactionRoleManager = class extends ReactionRolesManager {
  async getAllReactionRoles() {
   return db.get("reaction-role");
  }

  async saveReactionRole(messageID, reactionRoleData) {
    db.push("reaction-role", reactionRoleData);
    return true;
  }

  async deleteReactionRole(messageID,reaction){
    const array = db.get("reaction-role").filter((r) => r.messageID !== messageID || r.reaction !== reaction)
    
    db.set("reaction-role", array)

    return true;
  }
};

client.reactionRoleManager = new reactionRoleManager(client,{
  storage: false
})

client.login(settings.token);

Credits

Thanks to Androz2091 for helping me on this project.