From 554ebd21252f883f9bbf6598ed300f1641f41f57 Mon Sep 17 00:00:00 2001 From: chillingcone426 <89105733+chillingcone426@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:47:59 -0400 Subject: [PATCH 01/16] Update discord.js to latest version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b05a526..e5552bb 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ }, "homepage": "https://github.com/ryzyx/discordjs-button-pagination#readme", "dependencies": { - "discord.js": "^13.0.1" + "discord.js": "^14.11.0" } } From 0a40519f14cc7166fa04ab39f9e25fcc4169c9e2 Mon Sep 17 00:00:00 2001 From: chillingcone426 <89105733+chillingcone426@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:48:32 -0400 Subject: [PATCH 02/16] Fix index.js to work with latest version of discord.js --- index.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index f9fb6e8..96ebc42 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,10 @@ -const { - MessageActionRow, - Message, - MessageEmbed, - MessageButton, -} = require("discord.js"); +const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, ComponentType } = require('discord.js'); /** * Creates a pagination embed * @param {Interaction} interaction - * @param {MessageEmbed[]} pages - * @param {MessageButton[]} buttonList + * @param {EmbedBuilder[]} pages + * @param {ButtonBuilder[]} buttonList * @param {number} timeout * @returns */ @@ -29,7 +24,7 @@ const paginationEmbed = async ( let page = 0; - const row = new MessageActionRow().addComponents(buttonList); + const row = new ActionRowBuilder().addComponents(buttonList); //has the interaction already been deferred? If not, defer the reply. if (interaction.deferred == false) { @@ -42,21 +37,22 @@ const paginationEmbed = async ( fetchReply: true, }); - const filter = (i) => + const filter = (i) => { + i.deferUpdate(); i.customId === buttonList[0].customId || i.customId === buttonList[1].customId; - + }; const collector = await curPage.createMessageComponentCollector({ - filter, time: timeout, + componentType: ComponentType.Button, }); collector.on("collect", async (i) => { switch (i.customId) { - case buttonList[0].customId: + case "previousbtn": page = page > 0 ? --page : pages.length - 1; break; - case buttonList[1].customId: + case "nextbtn": page = page + 1 < pages.length ? ++page : 0; break; default: @@ -72,7 +68,7 @@ const paginationEmbed = async ( collector.on("end", (_, reason) => { if (reason !== "messageDelete") { - const disabledRow = new MessageActionRow().addComponents( + const disabledRow = new ActionRowBuilder().addComponents( buttonList[0].setDisabled(true), buttonList[1].setDisabled(true) ); From 2174279f3df4192ff065559c297f46a52af55f42 Mon Sep 17 00:00:00 2001 From: chillingcone426 <89105733+chillingcone426@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:49:46 -0400 Subject: [PATCH 03/16] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c62accf..a63fc81 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ paginationEmbed(interaction, pages, buttonList, timeout); ``` # Note +You must use the following custom ids for it to work. "previousbtn" and "nextbtn" This will not work with buttons whose style is set as 'LINK' as they do not trigger an interaction event. The buttons will auto disable once the the collector ends after the timeout. ## The collector timer resets after receiving a button interaction. From 8836f34b0faaf0db1d39bfe7d5a6336f226de401 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Mon, 17 Jul 2023 23:57:08 -0400 Subject: [PATCH 04/16] Updates naming --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e5552bb..b60c618 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "discordjs-button-pagination", + "name": "discordjs-button-pagination-v2", "version": "3.0.1", - "description": "A simple package for pagination using buttons introduced in discord.js v13.", + "description": "A simple package for pagination using buttons introduced in discord.js v13 that was updates to work with discord.js v14.", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -19,12 +19,12 @@ "discordjs", "discord.js" ], - "author": "Ryzyx", + "author": "thebeston123", "license": "MIT", "bugs": { - "url": "https://github.com/ryzyx/discordjs-button-pagination/issues" + "url": "https://github.com/chillingcone426/discordjs-button-pagination/issues" }, - "homepage": "https://github.com/ryzyx/discordjs-button-pagination#readme", + "homepage": "https://github.com/chillingcone426/discordjs-button-pagination#readme", "dependencies": { "discord.js": "^14.11.0" } From 3f24d76231e7b569b92d46e560d8e6afab9e2bcf Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:01:12 -0400 Subject: [PATCH 05/16] Updates to look good --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a63fc81..c45d0a9 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,8 @@ paginationEmbed(interaction, pages, buttonList, timeout); ``` # Note -You must use the following custom ids for it to work. "previousbtn" and "nextbtn" This will not work with buttons whose style is set as 'LINK' as they do not trigger an interaction event. The buttons will auto disable once the the collector ends after the timeout. +You must use the following custom ids for it to work. "previousbtn" and "nextbtn" ## The collector timer resets after receiving a button interaction. # Preview From 725dd76c6c407d169687f7416a48c23b2301f437 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:02:09 -0400 Subject: [PATCH 06/16] Fix a issue --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b60c618..9bd466a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/ryzyx/discordjs-button-pagination.git" + "url": "git+https://github.com/chillingcone426/discordjs-button-pagination.git" }, "keywords": [ "Discord", From 9844bb9c7734fd2e9e0d7c9c7e874fb3f571305b Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:03:48 -0400 Subject: [PATCH 07/16] Update Version Number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bd466a..581df21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordjs-button-pagination-v2", - "version": "3.0.1", + "version": "4.0.0", "description": "A simple package for pagination using buttons introduced in discord.js v13 that was updates to work with discord.js v14.", "main": "index.js", "scripts": { From 36b9a95c9d7f87a647e0e43fe9f0ca203b7f7904 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:05:18 -0400 Subject: [PATCH 08/16] More Updates to fix it. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c45d0a9..5b06134 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@

- NPM info + NPM info

@@ -104,5 +104,5 @@ Disabled Buttons after collector end -### For any issues or suggestions, kindly open an issue/pull request on the [**GitHub Repository**](https://github.com/ryzyx/discordjs-button-pagination) +### For any issues or suggestions, kindly open an issue/pull request on the [**GitHub Repository**](https://github.com/chillingcone426/discordjs-button-pagination) From 204d21744648ba289effac754fc69be27298bc6b Mon Sep 17 00:00:00 2001 From: chillingcone426 <89105733+chillingcone426@users.noreply.github.com> Date: Tue, 18 Jul 2023 00:06:46 -0400 Subject: [PATCH 09/16] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..6cdebaf --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From ef0e8b34a5d3326b29d85ef94d9685ee497c1169 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:16:27 -0400 Subject: [PATCH 10/16] Fix Issue --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b06134..04903c2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@

- NPM info + NPM info

From 5670ae18e5ceb526a1153d9d0b3bf94968493d94 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:17:08 -0400 Subject: [PATCH 11/16] Update Version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 581df21..082f2da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordjs-button-pagination-v2", - "version": "4.0.0", + "version": "4.0.1", "description": "A simple package for pagination using buttons introduced in discord.js v13 that was updates to work with discord.js v14.", "main": "index.js", "scripts": { From b9c8643fb66900501ede0ebc57500f8ba292926c Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:18:38 -0400 Subject: [PATCH 12/16] Update --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 04903c2..d32b9c2 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,8 @@ for slash command interaction. ## `discordjs-button-pagination@msg` for message command. # Installation -For `message` event -* `npm install discordjs-button-pagination@msg` -For `interaction` event -* `npm install discordjs-button-pagination@interaction` - -## Default command: `npm install discordjs-button-pagination` will install the **`interaction`** version +## Default command: `npm install discordjs-button-pagination-v2` will install the **`interaction`** version # Requirements Node.js 16.6.1 or newer is required along with Discord.js 13.0.0 or newer. From 16f57a2a1a2e29cdb3220425d9f697e5887abc2c Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:19:54 -0400 Subject: [PATCH 13/16] Update --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d32b9c2..cdcdc17 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,9 @@ A simple package to paginate discord embeds via discord buttons introduced in [d ## `discordjs-button-pagination@interaction` [Default] for slash command interaction. -## `discordjs-button-pagination@msg` -for message command. # Installation -## Default command: `npm install discordjs-button-pagination-v2` will install the **`interaction`** version +### Default command: `npm install discordjs-button-pagination-v2` # Requirements Node.js 16.6.1 or newer is required along with Discord.js 13.0.0 or newer. From 545075638ad79118927d7b54eff0494caa0de59f Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:21:01 -0400 Subject: [PATCH 14/16] Fix readme.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cdcdc17..4f023ef 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@

-# discordjs-button-pagination +# discordjs-button-pagination-v2 A simple package to paginate discord embeds via discord buttons introduced in [discord.js v13](https://github.com/discordjs/discord.js/tree/master). # Versions -## `discordjs-button-pagination@interaction` [Default] +## `discordjs-button-pagination-v2@interaction` [Default] for slash command interaction. # Installation @@ -26,7 +26,7 @@ Node.js 16.6.1 or newer is required along with Discord.js 13.0.0 or newer. __Basic Bot Example__ ```js // Import the discordjs-button-pagination package -const paginationEmbed = require('discordjs-button-pagination'); +const paginationEmbed = require('discordjs-button-pagination-v2'); // Use MessageEmbed to make pages // Keep in mind that Embeds should't have their footers set since the pagination method sets page info there From d8f32a73615cea9949beba8ec16c7cbdbebadce4 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:24:41 -0400 Subject: [PATCH 15/16] Fix README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4f023ef..244aaf3 100644 --- a/README.md +++ b/README.md @@ -30,24 +30,24 @@ const paginationEmbed = require('discordjs-button-pagination-v2'); // Use MessageEmbed to make pages // Keep in mind that Embeds should't have their footers set since the pagination method sets page info there -const { MessageEmbed , MessageButton} = require('discord.js'); -const embed1 = new MessageEmbed() +const { EmbedBuilder , ButtonBuilder, ButtonStyle} = require('discord.js'); +const embed1 = new EmbedBuilder() .setTitle('First Page') .setDescription('This is the first page'); -const embed2 = new MessageEmbed() +const embed2 = new EmbedBuilder() .setTitle('Second Page') .setDescription('This is the second page'); -const button1 = new MessageButton() +const button1 = new ButtonBuilder() .setCustomId('previousbtn') .setLabel('Previous') - .setStyle('DANGER'); + .setStyle(ButtonStyle.Danger); -const button2 = new MessageButton() +const button2 = new ButtonBuilder() .setCustomId('nextbtn') .setLabel('Next') - .setStyle('SUCCESS'); + .setStyle(ButtonStyle.Success); // Create an array of embeds pages = [ From 79dbd28df962f09f517fcd487078d114bf8614c6 Mon Sep 17 00:00:00 2001 From: chillingcone426 Date: Tue, 18 Jul 2023 00:25:17 -0400 Subject: [PATCH 16/16] Update Version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 082f2da..cde6588 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordjs-button-pagination-v2", - "version": "4.0.1", + "version": "4.0.2", "description": "A simple package for pagination using buttons introduced in discord.js v13 that was updates to work with discord.js v14.", "main": "index.js", "scripts": {