{"id":15647502,"url":"https://github.com/barbarbar338/reaction-role","last_synced_at":"2025-04-30T11:44:42.669Z","repository":{"id":39983847,"uuid":"240873952","full_name":"barbarbar338/reaction-role","owner":"barbarbar338","description":"ReactionRole is a module that allows you to create reaction role easily! Now with database support!","archived":false,"fork":false,"pushed_at":"2023-09-03T07:26:31.000Z","size":421,"stargazers_count":43,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T15:51:09.330Z","etag":null,"topics":["db","discord","discord-bot","discord-js","emoji","nodejs","reaction","reaction-role","role","rr"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/reaction-role","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barbarbar338.png","metadata":{"funding":{"github":"barbarbar338"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-16T10:45:03.000Z","updated_at":"2025-01-12T08:17:41.000Z","dependencies_parsed_at":"2024-06-18T21:10:05.978Z","dependency_job_id":"0dd79190-4b05-4fa1-9aee-b6229da93621","html_url":"https://github.com/barbarbar338/reaction-role","commit_stats":{"total_commits":94,"total_committers":5,"mean_commits":18.8,"dds":"0.32978723404255317","last_synced_commit":"0b57e5c366e7843a56dad237625917d257e929ab"},"previous_names":["barisbored/reaction-role"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbarbar338%2Freaction-role","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbarbar338%2Freaction-role/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbarbar338%2Freaction-role/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbarbar338%2Freaction-role/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barbarbar338","download_url":"https://codeload.github.com/barbarbar338/reaction-role/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251693014,"owners_count":21628607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["db","discord","discord-bot","discord-js","emoji","nodejs","reaction","reaction-role","role","rr"],"created_at":"2024-10-03T12:19:41.555Z","updated_at":"2025-04-30T11:44:42.606Z","avatar_url":"https://github.com/barbarbar338.png","language":"TypeScript","funding_links":["https://github.com/sponsors/barbarbar338"],"categories":[],"sub_categories":[],"readme":"# Discord ReactionRole client\r\n\r\n![totalDownloads](https://img.shields.io/npm/dt/reaction-role?style=for-the-badge)\r\n![weeklyDownloads](https://img.shields.io/npm/dw/reaction-role?style=for-the-badge)\r\n![version](https://img.shields.io/npm/v/reaction-role?style=for-the-badge)\r\n![license](https://img.shields.io/npm/l/reaction-role?style=for-the-badge)\r\n![GitHub stars](https://img.shields.io/github/stars/barbarbar338/reaction-role?style=for-the-badge)\r\n\r\n-   **ReactionRole** is a module that allows you to create Discord reaction role easily!\r\n-   This module is compatible with all node.js discord wrappers (like discord.js, eris, discord.js-commando etc.)\r\n-   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!\r\n-   Database support and TypeScript definitions are built-in!\r\n\r\n# IMPORTANT NOTE\r\n\r\n---\r\n\r\nYou have to turn on \"Server Members Intent\" option to use this package properly.\r\n![ReactionRoleWarningImage](https://raw.githubusercontent.com/barbarbar338/lib/master/personal_page/images/reaction-role-warning.png)\r\n\r\n# Usage\r\n\r\nSimple example:\r\n\r\n```js\r\nconst { ReactionRole, EType } = require(\"reaction-role\");\r\n\r\nconst client = new ReactionRole({\r\n\ttoken: \"YOUR_BOT_TOKEN\",\r\n});\r\n\r\nasync function bootstrap() {\r\n\tconst option1 = client.createOption({\r\n\t\tclickable_id: \"EMOJI_ID\",\r\n\t\troles: [\"ROLE_ID\"],\r\n\t\ttype: EType.NORMAL,\r\n\t});\r\n\r\n\tconst option2 = client.createOption({\r\n\t\tclickable_id: \"EMOJI_ID\",\r\n\t\troles: [\"ROLE_ID\"],\r\n\t\ttype: EType.ONCE,\r\n\t});\r\n\r\n\tawait client.createMessage({\r\n\t\tchannel_id: \"CHANNEL_ID\",\r\n\t\tclickables: [option1, option2],\r\n\t\tmessage_id: \"MESSAGE_ID\",\r\n\t});\r\n\r\n\tclient.init();\r\n}\r\n\r\nbootstrap();\r\n```\r\n\r\nCreating new messages:\r\n\r\n```js\r\nclient.on(\"message\", (message) =\u003e {\r\n\tif (message.content == \"!create\") {\r\n\t\t// you can take any user input and use it to create new option and message\r\n\r\n\t\t// create a simple option\r\n\t\tconst option = client.createOption({\r\n\t\t\tclickable_id: \"EMOJI_ID\",\r\n\t\t\troles: [\"ROLE_ID\"],\r\n\t\t\ttype: EType.NORMAL,\r\n\t\t});\r\n\r\n\t\tawait client.createMessage({\r\n\t\t\tchannel_id: \"CHANNEL_ID\",\r\n\t\t\tclickables: [option],\r\n\t\t\tmessage_id: \"MESSAGE_ID\",\r\n\t\t});\r\n\r\n\t\t// and you are done! New message and options are added to system\r\n\t}\r\n});\r\n```\r\n\r\n# Execute Custom Code\r\n\r\nYou can execute your own code when a user clicks on a reaction. You can do this by using clickable type `EType.CUSTOM`.\r\n\r\n```js\r\nconst { ReactionRole, EType } = require(\"reaction-role\");\r\n\r\nconst client = new ReactionRole({\r\n\ttoken: \"YOUR_BOT_TOKEN\",\r\n});\r\n\r\nasync function bootstrap() {\r\n\tconst option = client.createOption({\r\n\t\tclickable_id: \"EMOJI_ID\",\r\n\t\troles: [\"ROLE_ID\"],\r\n\r\n\t\t// These lines are important! everything else is same as normal\r\n\t\ttype: EType.CUSTOM,\r\n\t\tonClick: (clickable, member) =\u003e {\r\n\t\t\tconsole.log(\r\n\t\t\t\tmember.user.username + \" clicked on \" + clickable.clickable_id,\r\n\t\t\t);\r\n\t\t},\r\n\t\tonRemove: (clickable, member) =\u003e {\r\n\t\t\tconsole.log(\r\n\t\t\t\tmember.user.username + \" removed \" + clickable.clickable_id,\r\n\t\t\t);\r\n\t\t},\r\n\t});\r\n\r\n\tawait client.createMessage({\r\n\t\tchannel_id: \"CHANNEL_ID\",\r\n\t\tclickables: [option],\r\n\t\tmessage_id: \"MESSAGE_ID\",\r\n\t});\r\n\r\n\tclient.init();\r\n}\r\n\r\nbootstrap();\r\n```\r\n\r\n# Using Custom Databases\r\n\r\nYou can change get, save and delete events of system with `\u003cReactionRole\u003e.onGet(TOnGetFN)`, `\u003cReactionRole\u003e.onSet(TOnSetFN)` and `\u003cReactionRole\u003e.onDelete(TOnDeleteFN)` methods. Here is an example with `quick.db`:\r\n\r\n```js\r\nconst { ReactionRole, EType } = require(\"reaction-role\");\r\n\r\nconst client = new ReactionRole({\r\n\ttoken: \"YOUR_BOT_TOKEN\",\r\n});\r\n\r\n// SETTING CUSTOM DATABASE START\r\n// choose your favourite database module\r\nconst db = require(\"quick.db\");\r\n\r\n// update save events\r\nclient\r\n\t.onGet(async () =\u003e {\r\n\t\tconst saved = (await db.get(\"reaction_roles\")) || {};\r\n\t\treturn saved;\r\n\t})\r\n\t.onSet(async (data) =\u003e {\r\n\t\tawait db.set(\"reaction_roles\", data);\r\n\t})\r\n\t.onDelete(async (message_id) =\u003e {\r\n\t\tawait db.delete(`reaction_roles.${message_id}`);\r\n\t});\r\n// SETTING CUSTOM DATABASE END\r\n\r\n// ... use it as normal\r\n```\r\n\r\n# Useful Links\r\n\r\n-   Discord: https://338.rocks/discord\r\n-   Github: https://github.com/barbarbar338/reaction-role/\r\n-   NPM: https://www.npmjs.com/package/reaction-role\r\n\r\n# [Contact Me For More Help](https://338.rocks/discord)\r\n\r\n\\ ゜ o ゜)ノ\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbarbar338%2Freaction-role","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarbarbar338%2Freaction-role","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbarbar338%2Freaction-role/lists"}