{"id":15063353,"url":"https://github.com/inkohx/discord.js-reaction-controller","last_synced_at":"2025-10-04T22:32:02.232Z","repository":{"id":37797749,"uuid":"261164163","full_name":"InkoHX/discord.js-reaction-controller","owner":"InkoHX","description":"Discord.js Reaction Controller","archived":true,"fork":false,"pushed_at":"2022-09-14T16:08:56.000Z","size":169,"stargazers_count":3,"open_issues_count":8,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-30T08:23:26.671Z","etag":null,"topics":["discord-bot","discordjs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/discord.js-reaction-controller","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/InkoHX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-04T12:04:06.000Z","updated_at":"2023-01-27T21:13:46.000Z","dependencies_parsed_at":"2022-06-22T17:04:09.744Z","dependency_job_id":null,"html_url":"https://github.com/InkoHX/discord.js-reaction-controller","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InkoHX%2Fdiscord.js-reaction-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InkoHX%2Fdiscord.js-reaction-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InkoHX%2Fdiscord.js-reaction-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InkoHX%2Fdiscord.js-reaction-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InkoHX","download_url":"https://codeload.github.com/InkoHX/discord.js-reaction-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235321067,"owners_count":18971238,"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":["discord-bot","discordjs","typescript"],"created_at":"2024-09-24T23:55:34.363Z","updated_at":"2025-10-04T22:31:56.959Z","avatar_url":"https://github.com/InkoHX.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discord.js-reaction-controller\n\n[![Scrapbox](https://img.shields.io/badge/Scrapbox-docs-green)](https://scrapbox.io/discordjs-japan/リアクションを使って簡単にページネーションを作成するDiscord.js専用のパッケージ)\n\n![Discord.js Reaction Controller](https://i.imgur.com/JOJJZF6.gif)\n\n## Install\n\n### Requirements\n\n- Discord.js v12.2.0 or later\n\n### NPM\n\n```bash\nnpm install discord.js-reaction-controller\n```\n\n### Yarn\n\n```bash\nyarn add discord.js-reaction-controller\n```\n\n## Example of usage\n\n```js\nconst Discord = require('discord.js')\nconst { ReactionController } = require('discord.js-reaction-controller')\n\nconst client = new Discord.Client()\n\nclient.on('message', message =\u003e {\n  if (message.content.startsWith('\u003epagination')) {\n    const controller = new ReactionController(client)\n\n    controller\n      .addReactionHandler('🤔', (reaction) =\u003e {\n        reaction.message.channel.send('thinking')\n          .catch(console.error)\n      })\n\n    controller.addPages([\n      new Discord.MessageEmbed().setImage('https://github.com/yyx990803.png'),\n      new Discord.MessageEmbed().setImage('https://github.com/egoist.png'),\n      new Discord.MessageEmbed().setImage('https://github.com/vercel.png'),\n      new Discord.MessageEmbed().setImage('https://github.com/Google.png'),\n      new Discord.MessageEmbed().setImage('https://github.com/Microsoft.png')\n    ])\n\n    controller.sendTo(message.channel, message.author)\n      .catch(console.error)\n  }\n})\n\nclient.login()\n  .catch(console.error)\n```\n\n### Using Promise (Lazy Loading)\n\nIt is recommended to create a function that returns MessageEmbed with Promise and put it in the argument of addPages and addPage when there are many processes to access externally through the network.\n\nThat way, \"discord.js-reaction-controller\" will resolve the promises as needed and cache and display the MessageEmbed.\n\n```js\nconst { Client, MessageEmbed } = require('discord.js')\nconst { ReactionController } = require('discord.js-reaction-controller')\nconst { getBasicInfo } = require('ytdl-core')\n\nconst client = new Client()\n\nconst fetchYouTubeVideoInfo = videoUrl =\u003e async () =\u003e {\n  const { videoDetails } = await getBasicInfo(videoUrl)\n\n  return new MessageEmbed()\n    .setColor('RED')\n    .setTitle(videoDetails.title)\n    .setURL(videoDetails.video_url)\n    .setImage(videoDetails.thumbnails[videoDetails.thumbnails.length - 1].url)\n    .setTimestamp(Date.parse(videoDetails.publishDate))\n    .setFooter('Uploaded on')\n    .setAuthor(videoDetails.author.name, videoDetails.author.thumbnails[0].url, videoDetails.author.channel_url)\n}\n\n\nconst videos = [\n  'https://youtu.be/sWbD5q769Ms',\n  'https://youtu.be/0-zJNiSvz8Q',\n  'https://youtu.be/1x2izJEN9p0',\n  'https://youtu.be/gNp4VNr44hg',\n  'https://youtu.be/Vi_asBY5UX8',\n  'https://youtu.be/plqoPcKQnyE',\n  'https://youtu.be/308I91ljCWg'\n]\n\nclient.on('message', message =\u003e {\n  if (message.content.startsWith('\u003epagination')) {\n    const controller = new ReactionController(client)\n\n    controller\n      .addReactionHandler('🤔', (reaction) =\u003e {\n        reaction.message.channel.send('thinking')\n          .catch(console.error)\n      })\n\n    controller.addPages(videos.map(url =\u003e fetchYouTubeVideoInfo(url)))\n\n    controller.sendTo(message.channel, message.author)\n      .catch(console.error)\n  }\n})\n\nclient.login()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkohx%2Fdiscord.js-reaction-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finkohx%2Fdiscord.js-reaction-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkohx%2Fdiscord.js-reaction-controller/lists"}