{"id":27715825,"url":"https://github.com/muricans/discord-embedbuilder","last_synced_at":"2025-04-27T01:32:59.906Z","repository":{"id":45953764,"uuid":"191477453","full_name":"muricans/discord-embedbuilder","owner":"muricans","description":"npm module to make creating embeds with mutliple pages a little bit easier","archived":false,"fork":false,"pushed_at":"2022-10-23T03:24:26.000Z","size":115,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-21T17:47:08.727Z","etag":null,"topics":["discord-js","embeds","npm-package","typescript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/muricans.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":"2019-06-12T01:47:45.000Z","updated_at":"2024-12-16T14:24:14.000Z","dependencies_parsed_at":"2023-01-20T10:15:36.654Z","dependency_job_id":null,"html_url":"https://github.com/muricans/discord-embedbuilder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muricans%2Fdiscord-embedbuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muricans%2Fdiscord-embedbuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muricans%2Fdiscord-embedbuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muricans%2Fdiscord-embedbuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muricans","download_url":"https://codeload.github.com/muricans/discord-embedbuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251077102,"owners_count":21532607,"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-js","embeds","npm-package","typescript"],"created_at":"2025-04-27T01:32:02.483Z","updated_at":"2025-04-27T01:32:59.861Z","avatar_url":"https://github.com/muricans.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discord-embedbuilder\n[![dependencies Status](https://david-dm.org/muricans/discord-embedbuilder/status.svg)](https://david-dm.org/muricans/discord-embedbuilder)\n\n[![NPM](https://nodei.co/npm/discord-embedbuilder.png?downloads=true)](https://nodei.co/npm/discord-embedbuilder)\n\nnpm module to make creating embeds with mutliple pages a little bit easier\n\n[latest version documentation](http://github.muricans.xyz/embedbuilder)\n\n[master documentation](http://github.muricans.xyz/embedbuilder/master)\n\n## Quick Install\n\ndiscord-embedbuilder v4.0.0(current stable)\n\n`npm install discord-embedbuilder`\n\ndiscord-embedbuilder master (v4.0.0)\n\n`npm install muricans/discord-embedbuilder`\n\ndiscord-embedbuilder uses the latest stable version of discord.js (14.6.0)\n\n## Methods\nAll methods that have the same names as the ones from [EmbedBuilder](https://discord.js.org/#/docs/builders/main/class/EmbedBuilder) do the same actions as those, but applies it to all of the pages, which should override their values.\n\n### `usePages(use)`\n\nIf this is set to false, the builder will not use the next, back, last, first, stop emotes.\n\n\u003chr/\u003e\n\n### `changeChannel(channel)`\n\nChange the current channel.\n\n**\u003cspan style=\"color:red\"\u003eWarning:\u003c/span\u003e** This should not be used to set the channel. You can set the channel in the constructor.\n\n\u003chr/\u003e\n\n### `setEmbeds(embeds)`\n\nThe array of EmbedBuilders put here will be the ones that are used to make the pages. You can also add embeds using addEmbed.\n\n\u003chr/\u003e\n\n### `addEmbed(embed)`\n\nAdds an EmbedBuilder to the array of embeds.\n\n\u003chr/\u003e\n\n### `concatEmbeds(embeds)`\n\nPuts the array of embeds given at the end of the current embeds array.\n\n\u003chr/\u003e\n\n### `setEndColor(color)`\n\nWhen the collection has ended, and no other custom color is being used, this will be the color the embed is set to. Default is 0xE21717\n\n\u003chr/\u003e\n\n### `setTime(time)`\n\nThis will set how long the builder should listen for emotes. Make sure to set your time as milliseconds.\n\n\u003chr/\u003e\n\n### `addTime(time)`\n\nUse after the embed has been built. Will increase the amount of time the collector is active before it stops.\n\n\u003chr/\u003e\n\n### `resetTimer(time?)`\n\nResets the timer to either the time already set, or a new time given.\n\n\u003chr/\u003e\n\n### `addTimeOnPage(time)`\n\nWhenever the builder changes it's page, it will add specified amount of time (ms) to the current running timer.\n\n\u003chr/\u003e\n\n### `resetTimerOnPage()`\n\nWhenever the builder changes it's page, it will reset the timer to the current set time.\n\n\u003chr/\u003e\n\n### `addEmoji(emoji, (sent, page, builder, emoji))`\n\nThis will insert the provided emoji into the builder, and when it is clicked it will perform the action that is provided.\n\n```javascript\nbuilder.addEmoji('❗', (sent, page, emoji) =\u003e {\n    sent.delete();\n    builder.cancel();\n    sent.channel.send(`A new message${emoji}\\nThe page you were on before was ${page}`);\n});\n```\n\n\u003chr/\u003e\n\n### `addEmojis(emojis)`\n\nAdd multiple emojis to do different actions.\n\n```javascript\nbuilder.addEmojis([{\n    '❗': (sent, page, emoji) =\u003e {\n        builder.cancel();\n        sent.delete();\n        sent.channel.send(`A new message${emoji}\\nThe page you were on before was ${page}`);\n    },\n}]);\n```\n\n\u003chr/\u003e\n\n### `deleteEmoji(emoji)`\n\nDeletes an emoji from the list of emojis.\n\n\u003chr/\u003e\n\n### `cancel(callback?)`\n\nCancels the builder before the timer ends.\n\nIf a callback is provided, it will execute after the builder has canceled.\n\n\u003chr/\u003e\n\n### `showPageNumber(use)`\n\nIf set to true (by default it is true), it will show the current page on the footer of the embed. (Page x/y)\n\n\u003chr/\u003e\n\n### `setPageFormat(format)`\n\nIf showing page numbers, this is the format that will be used.\n\nBy default format is %p/%m which converts to current/max.\n\n\u003chr/\u003e\n\n### `calculatePages(data, dataPerPage, insert)`\n\nThis calculates pages for the builder to work with.\n\n```javascript\n/*\nThis will generate a builder with a data length set to an array.\nIt will have 10 fields per page, which will all be inline, containing username and points data.\n*/\nembedBuilder.calculatePages(users.length, 10, (embed, i) =\u003e {\n    embed.addField(users[i].username, users[i].points, true);\n});\n```\n\n\u003chr/\u003e\n\n### `calculatePagesAsync(data, dataPerPage, insert)`\n\nAsync version of calculatePages\n\nMakes the page calculator wait for operations to finish.\n```javascript\nawait embedBuilder.calculatePagesAsync(users.length, 10, async (embed, i) =\u003e {\n    const user = await getSomeUser(users[i]);\n    embed.addField(user.username, user.points, true);\n});\n```\n\n\u003chr/\u003e\n\n### `updatePage(page)`\n\nUpdates the current page to the one set there. This checks if the page is valid itself. Make sure the first page of the builder has already gone through before using this.\n\n\u003chr/\u003e\n\n### `setPageEmoji(emoji, newEmoji)`\n\nReplaces current type of emoji given with the new emoji provided.\n\nTypes allowed: back, first, stop, last, next\n\n\u003chr/\u003e\n\n### `awaitPageUpdate(user, options)`\n\n[options](http://github.muricans.xyz/embedbuilder/interfaces/PageUpdateOptions.html)\n\nCreate an updater to await responses from a user,\nthen set the builders current page to the page given.\n\n\u003chr/\u003e\n\n### `defaultReactions(reactions)`\n\nThe reactions the bot will use. If this  method is not used in the builder, the bot will automatically add all reactions.\n\n```javascript\n/*\n* This builder will only use the stop and back emojis. \n* Using this also allows you to rearrange the order in which the bot will react with the emojis.\n*/\nembedBuilder.defaultReactions(['stop', 'back']);\n```\n\n\u003chr/\u003e\n\n## Events\n### [`create`](http://github.muricans.xyz/embedbuilder/classes/PageEmbedBuilder.html#create)\n\nEmitted from build() when the first page has finished building.\n\n### [`stop`](http://github.muricans.xyz/embedbuilder/classes/PageEmbedBuilder.html#stop)\n\nEmitted from build() when the timer has run out, or the collector is canceled in any way.\n\n### [`pageUpdate`](http://github.muricans.xyz/embedbuilder/classes/PageEmbedBuilder.html#pageupdate)\n\nEmitted from from build() when the builder has changed pages. Sets the new page for the bot.\n\n### [`preSend`](http://github.muricans.xyz/embedbuilder/classes/PageEmbedBuilder.html#presend)\n\nEmitted from build() before the first embed page has been sent in Discord.\n\n## PageUpdater\nPageUpdater documentation can be found [here](http://github.muricans.xyz/embedbuilder/classes/PageUpdater.html).\n\n## Example\nFirst import discord-embedbuilder into your project.\n\n```javascript\nconst {\n    PageEmbedBuilder,\n } = require('discord-embedbuilder');\n```\n\nCreate a command or some way to get a channel to pass through the builder. If you are unsure on how to make a command, checking [this](https://discordjs.guide/) out might be helpful.\n\nNext make your PageEmbedBuilder.\n\n```javascript\nclient.on('message', message =\u003e {\n    const builder = new PageEmbedBuilder()\n        .setChannel(message.channel)\n        .setTime(60000); // Time is in milliseconds\n    const myEmbedArray = [\n        new Discord.EmbedBuilder().addFields({name:'1st', value:'page'}),\n        new Discord.EmbedBuilder().addFields({name:'2nd', value:'page'}), \n        new Discord.EmbedBuilder().addFields({name:'3rd', value:'page'}),\n    ];\n    builder\n        .setEmbeds(myEmbedArray)\n        .setTitle('This title stays the same on all pages!')\n        .build(); // No need to send a message, building it will automatically do it.\n});\n```\n\nHere's an example taken from my bot [rolesbot](https://github.com/muricans/rolesbot/)\n\n```javascript\nconst rolebot = require('../rolebot');\nconst fs = require('fs');\nconst {\n    PageEmbedBuilder,\n} = require('discord-embedbuilder');\n\nmodule.exports = {\n    name: 'list',\n    description: 'Refreshes and lists all currently active role react messages.',\n    permissions: ['MANAGE_GUILD'],\n    async execute(message) {\n        rolebot.refreshActiveMessagesFor(message.guild.id);\n        const messages = JSON.parse(fs.readFileSync('./messages.json', 'utf-8'));\n        const list = messages.ids.filter(v =\u003e v.guildId === message.guild.id);\n        if (list.length \u003e 0) {\n            const builder = new PageEmbedBuilder(message.channel);\n            const guild = await message.guild.fetch();\n            builder.calculatePages(list.length, 8, async (embed, i) =\u003e {\n                    const channelName = guild.channels.cache.get(list[i].channelId);\n                    const roleName = guild.roles.cache.get(list[i].roleId);\n                    embed.addField(\"Message ID\", list[i].messageId, true);\n                    embed.addField(\"Channel\", `${channelName}`, true);\n                    embed.addField(\"Role\", `${roleName}`, true);\n                })\n                .setTitle(\"List of All Active Messages\")\n                .build();\n        } else {\n            message.channel.send(`${message.author} No messages are currently registered in this guild!`);\n        }\n    },\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuricans%2Fdiscord-embedbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuricans%2Fdiscord-embedbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuricans%2Fdiscord-embedbuilder/lists"}