# reaction-role

> ReactionRole is a module that allows you to create Discord reaction role easily!

Latest version **5.2.1** (published 2026-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install reaction-role
pnpm add reaction-role
yarn add reaction-role
bun add reaction-role
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.2.1 |
| Published | 2026-01-25 |
| First published | 2020-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 37.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 42 |
| Author | Barış DEMİRCİ |
| Maintainers | barbarbar338 |
| Keywords | discord, bot, reaction, role, reaction-role, discord-bot, emoji, role, emoji-role, rr, db, permanent |

## Links

- npm: https://www.npmjs.com/package/reaction-role
- Repository: https://github.com/barbarbar338/reaction-role
- Homepage: https://github.com/barbarbar338/reaction-role#readme
- Issues: https://github.com/barbarbar338/reaction-role/issues
- npm.io page: https://npm.io/package/reaction-role

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.23
- [bookman](https://npm.io/package/bookman.md) ^4.0.0
- [discord.js](https://npm.io/package/discord.js.md) ^14.25.1
- [@hammerhq/logger](https://npm.io/package/@hammerhq/logger.md) ^2.2.0

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 5.2.1 (latest) — 2026-01-25
- 5.2.0 — 2026-01-25
- 5.0.1 — 2022-12-14
- 5.0.0 — 2022-10-08
- 4.1.1 — 2021-06-11
- 4.1.0 — 2021-04-26
- 4.0.3 — 2021-04-25
- 4.0.2 — 2021-04-18
- 4.0.1 — 2021-04-18
- 4.0.0 — 2021-04-18
- 3.2.3 — 2021-01-21
- 3.2.2 — 2021-01-07
- 3.2.1 — 2020-12-21
- 3.2.0 — 2020-12-19
- 3.1.0 — 2020-10-31
- … 21 more at https://npm.io/package/reaction-role/versions

## README

# Discord ReactionRole client

![totalDownloads](https://img.shields.io/npm/dt/reaction-role?style=for-the-badge)
![weeklyDownloads](https://img.shields.io/npm/dw/reaction-role?style=for-the-badge)
![version](https://img.shields.io/npm/v/reaction-role?style=for-the-badge)
![license](https://img.shields.io/npm/l/reaction-role?style=for-the-badge)
![GitHub stars](https://img.shields.io/github/stars/barbarbar338/reaction-role?style=for-the-badge)

- **ReactionRole** is a module that allows you to create Discord reaction role easily!
- This module is compatible with all node.js discord wrappers (like discord.js, eris, discord.js-commando etc.)
- You also don't need to write any bot code if you want! You can also use this module alone. You just need a Discord Bot Token!
- Database support and TypeScript definitions are built-in!

# IMPORTANT NOTE

---

You have to turn on "Server Members Intent" option to use this package properly.
![ReactionRoleWarningImage](https://raw.githubusercontent.com/barbarbar338/lib/master/personal_page/images/reaction-role-warning.png)

# Usage

Simple example:

```js
const { ReactionRole, EType } = require("reaction-role");

const client = new ReactionRole({
	token: "YOUR_BOT_TOKEN",
});

async function bootstrap() {
	const option1 = client.createOption({
		clickable_id: "EMOJI_ID",
		roles: ["ROLE_ID"],
		type: EType.NORMAL,
	});

	const option2 = client.createOption({
		clickable_id: "EMOJI_ID",
		roles: ["ROLE_ID"],
		type: EType.ONCE,
	});

	await client.createMessage({
		channel_id: "CHANNEL_ID",
		clickables: [option1, option2],
		message_id: "MESSAGE_ID",
	});

	client.init();
}

bootstrap();
```

Creating new messages:

```js
client.on("message", (message) => {
	if (message.content == "!create") {
		// you can take any user input and use it to create new option and message

		// create a simple option
		const option = client.createOption({
			clickable_id: "EMOJI_ID",
			roles: ["ROLE_ID"],
			type: EType.NORMAL,
		});

		await client.createMessage({
			channel_id: "CHANNEL_ID",
			clickables: [option],
			message_id: "MESSAGE_ID",
		});

		// and you are done! New message and options are added to system
	}
});
```

# Execute Custom Code

You can execute your own code when a user clicks on a reaction. You can do this by using clickable type `EType.CUSTOM`.

```js
const { ReactionRole, EType } = require("reaction-role");

const client = new ReactionRole({
	token: "YOUR_BOT_TOKEN",
});

async function bootstrap() {
	const option = client.createOption({
		clickable_id: "EMOJI_ID",
		roles: ["ROLE_ID"],

		// These lines are important! everything else is same as normal
		type: EType.CUSTOM,
		onClick: (clickable, member) => {
			console.log(
				member.user.username + " clicked on " + clickable.clickable_id,
			);
		},
		onRemove: (clickable, member) => {
			console.log(
				member.user.username + " removed " + clickable.clickable_id,
			);
		},
	});

	await client.createMessage({
		channel_id: "CHANNEL_ID",
		clickables: [option],
		message_id: "MESSAGE_ID",
	});

	client.init();
}

bootstrap();
```

# Using Custom Databases

You can change get, save and delete events of system with `<ReactionRole>.onGet(TOnGetFN)`, `<ReactionRole>.onSet(TOnSetFN)` and `<ReactionRole>.onDelete(TOnDeleteFN)` methods. Here is an example with `quick.db`:

```js
const { ReactionRole, EType } = require("reaction-role");

const client = new ReactionRole({
	token: "YOUR_BOT_TOKEN",
});

// SETTING CUSTOM DATABASE START
// choose your favourite database module
const db = require("quick.db");

// update save events
client
	.onGet(async () => {
		const saved = (await db.get("reaction_roles")) || {};
		return saved;
	})
	.onSet(async (data) => {
		await db.set("reaction_roles", data);
	})
	.onDelete(async (message_id) => {
		await db.delete(`reaction_roles.${message_id}`);
	});
// SETTING CUSTOM DATABASE END

// ... use it as normal
```

# Useful Links

- Discord: https://338.rocks/discord
- Github: https://github.com/barbarbar338/reaction-role/
- NPM: https://www.npmjs.com/package/reaction-role

# [Contact Me For More Help](https://338.rocks/discord)

\ ゜ o ゜)ノ

---
_Source: https://npm.io/package/reaction-role · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
