{"id":15045010,"url":"https://github.com/luke265/discord-button-width","last_synced_at":"2026-02-07T00:03:23.093Z","repository":{"id":57685896,"uuid":"477344851","full_name":"Luke265/discord-button-width","owner":"Luke265","description":"Make your discord buttons almost equal width","archived":false,"fork":false,"pushed_at":"2024-05-12T16:47:26.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-03T09:19:06.654Z","etag":null,"topics":["discord","discord-bot","discord-js","discordjs"],"latest_commit_sha":null,"homepage":"","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/Luke265.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2022-04-03T13:09:13.000Z","updated_at":"2024-08-03T17:00:06.000Z","dependencies_parsed_at":"2024-09-25T01:56:30.972Z","dependency_job_id":"7391d899-4f7c-456f-9d07-6cc3110a90af","html_url":"https://github.com/Luke265/discord-button-width","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Luke265/discord-button-width","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luke265%2Fdiscord-button-width","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luke265%2Fdiscord-button-width/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luke265%2Fdiscord-button-width/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luke265%2Fdiscord-button-width/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Luke265","download_url":"https://codeload.github.com/Luke265/discord-button-width/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luke265%2Fdiscord-button-width/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266287824,"owners_count":23905461,"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","discord-bot","discord-js","discordjs"],"created_at":"2024-09-24T20:51:20.848Z","updated_at":"2026-02-07T00:03:23.051Z","avatar_url":"https://github.com/Luke265.png","language":"TypeScript","readme":"# About\nMake your [discord buttons](https://discord.com/developers/docs/interactions/message-components) almost equal width.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/Luke265/discord-button-width/main/images/result.png\" /\u003e\n\u003c/p\u003e\n\n# Installation\n\n```\nnpm i discord-button-width\nyarn add discord-button-width\npnpm i discord-button-width\n```\n\n# Example usage\n```ts\nimport { MessageActionRowComponentResolvable, MessageButtonOptions } from \"discord.js\";\nimport { getStringWidth, padStringToWidth } from \"discord-button-width\";\n\nconst buttons: MessageButtonOptions[] = [\n    {\n        customId: \"1\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Eastern White Pine\",\n    },\n    {\n        customId: \"2\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Daffodil\",\n    },\n    {\n        customId: \"3\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Dawn Redwood\",\n    },\n    {\n        customId: \"4\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Dark Opal Basil\",\n    },\n    {\n        customId: \"5\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Gerber\",\n    },\n    {\n        customId: \"6\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Incrediball Hydrangea\",\n    },\n    {\n        customId: \"7\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Pale Purple Coneflower\",\n    },\n    {\n        customId: \"8\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Lamb's Ear\",\n    },\n    {\n        customId: \"9\",\n        type: \"BUTTON\",\n        style: \"PRIMARY\",\n        label: \"Nasturtium\",\n    },\n];\nconst maxWidth = Math.max(\n    ...buttons.map((button) =\u003e getStringWidth(button.label!))\n);\nfor (const button of buttons) {\n    button.label = padStringToWidth(button.label!, maxWidth, Align.LEFT);\n}\nmessage.reply({\n    components: [\n        {\n            type: \"ACTION_ROW\",\n            components: buttons.slice(0, 3) as MessageActionRowComponentResolvable[],\n        },\n        {\n            type: \"ACTION_ROW\",\n            components: buttons.slice(3, 6) as MessageActionRowComponentResolvable[],\n        },\n        {\n            type: \"ACTION_ROW\",\n            components: buttons.slice(6, 9) as MessageActionRowComponentResolvable[],\n        },\n    ],\n});\n```\n\n# Supported characters\n\nCurrently this library supports these characters: \n```\nabcdefghijklmnopqrstuvwxyząčęėįšųūžABCDEFGHIJKLMNOPQRSTUVWXYZĄČĘĖĮŠŲŪŽ0123456789/*-,._?!#@$%^\u0026=\u003c\u003e\\\\|/\\\"';:{}[]()`~\\u0020\n```\n\nIf you want to use other characters you can submit a pull request, or extend character map for yourself:\n\n```ts\nimport { DiscordButtonWidthUtil, CHAR_MAP, PAD_MAP } from \"discord-button-width\";\n\nconst charMap = Object.assign(CHAR_MAP, {\n  \"A\": 9.5\n  // character: character width\n});\nconst dcButton = new DiscordButtonWidthUtil(charMap, PAD_MAP);\ndcButton.padStringToWidth(\"Your text\", 60);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluke265%2Fdiscord-button-width","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluke265%2Fdiscord-button-width","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluke265%2Fdiscord-button-width/lists"}