{"id":19660642,"url":"https://github.com/modcord/message-parser","last_synced_at":"2025-04-28T20:32:23.360Z","repository":{"id":42657997,"uuid":"259904118","full_name":"ModCord/message-parser","owner":"ModCord","description":"A message parser for discord using regular expressions and string manipulation.","archived":false,"fork":false,"pushed_at":"2023-01-07T06:37:36.000Z","size":859,"stargazers_count":3,"open_issues_count":6,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T16:04:39.649Z","etag":null,"topics":["custom-emoji","discord","message-parser","parsing-spoilers","string-manipulation"],"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/ModCord.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-04-29T11:15:34.000Z","updated_at":"2024-01-23T18:33:58.000Z","dependencies_parsed_at":"2023-02-06T14:16:06.974Z","dependency_job_id":null,"html_url":"https://github.com/ModCord/message-parser","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/ModCord%2Fmessage-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModCord%2Fmessage-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModCord%2Fmessage-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModCord%2Fmessage-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ModCord","download_url":"https://codeload.github.com/ModCord/message-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224134018,"owners_count":17261302,"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":["custom-emoji","discord","message-parser","parsing-spoilers","string-manipulation"],"created_at":"2024-11-11T16:04:44.685Z","updated_at":"2024-11-11T16:04:45.560Z","avatar_url":"https://github.com/ModCord.png","language":"TypeScript","readme":"# Discord Message Parser\n- Has zero dependencies.\n- A message parser for discord using regular expressions and string manipulation.\n- If you need help feel free to join our \u003ca href=\"https://discord.gg/rk7cVyk\"\u003ediscord server\u003c/a\u003e to talk and help you with your code.\n- If you encounter any of those fell free to open an issue in our \u003ca href=\"https://github.com/ModCord/message-parser/issues\"\u003egithub repository\u003c/a\u003e.\n\n# Download \u0026 Update\nYou can download it from npm:\n```cli\nnpm i discord-message-parser\n```\nYou can update to a newer version to receive updates using npm.\n```cli\nnpm update discord-message-parser\n```\n\n# Changelog\n**3rd of April** (v1.0.0) - Original publication to node package manager.\n\n# Setting Up\nFirst things first, we include the module into the project.\n```js\nconst MessageParser = require(\"discord-message-parser\");\nconst { SpoilerParser, EmojiParser } = MessageParser;\n```\n\n# Examples\n*Examples assume that you have setted up the module as presented in 'Setting Up' section.*\n*Following examples assume that your `Discord.Client` is called `client`.*\n\n*Following examples assume that your `client.on(\"message\", message` is called `message`.*\n\n*Following example contains isolated code which you need to integrate in your own command handler.*\n- **Counting emojis in a message:**\n```js\nclient.on(\"message\", (message) =\u003e {\n  const emojiCount = EmojiParser.countEmojis(message.content);\n  console.log(emojiCount);\n  /*  Sample output: \n     {\n       custom: 1,\n       animated: 0,\n       unicode: 2,\n       total: 3\n     }\n  */\n});\n```\n\n- **Parsing emojis in a message:**\n```js\nclient.on(\"message\", (message) =\u003e {\n  const messageEmojis = EmojiParser.parseEmojis(message.content);\n  console.log(messageEmojis);\n  /* Sample output:\n  {\n      custom: [{ name: \"doggo\", id: \"393852367751086090\", raw: \"\u003c:doggo:393852367751086090\u003e\", animated: false, unicode: false }],\n      customAnimated: [{ name: \"dogdance\", id: \"663013890376073257\", raw: \"\u003c:dogdance:663013890376073257\u003e\", animated: true, unicode: false }],\n      customEmojis: [{ name: \"doggo\", id: \"393852367751086090\", raw: \"\u003c:doggo:393852367751086090\u003e\", animated: false, unicode: false }, { name: \"dogdance\", id: \"663013890376073257\", raw: \"\u003c:dogdance:663013890376073257\u003e\", animated: true, unicode: false }],\n      unicode: [{ name: null, id: null, raw: \"⏱️\", animated: null, unicode: true }, { name: null, id: null, raw: \"☕\", animated: null, unicode: true }],\n      allEmojis: [{ name: \"doggo\", id: \"393852367751086090\", raw: \"\u003c:doggo:393852367751086090\u003e\", animated: false, unicode: false }, { name: \"dogdance\", id: \"663013890376073257\", raw: \"\u003c:dogdance:663013890376073257\u003e\", animated: true, unicode: false }, { name: null, id: null, raw: \"⏱️\", animated: null, unicode: true }, { name: null, id: null, raw: \"☕\", animated: null, unicode: true }]\n  }\n  */\n});\n```\n\n- **Parsing spoilers in a message:**\n```js\nclient.on(\"message\", (message) =\u003e {\n  const messageSpoilers = SpoilerParser.parseSpoilers(message.content);\n  console.log(messageSpoilers);\n  /* Sample Output\n  [\n    { content: 'is killed', raw: '||is killed||' },\n    { content: 'married tom', raw: '||married tom||' }\n  ]\n  */\n});\n```\n*Is time for you to get creative..*\n\n# Methods\n\n\n## 1. Emoji Parsing API\n**\\_parseCustomEmojis** - *Used internally by the library*\n\nParses the non-animated custom emojis from a string.\n```js\nEmojiParser._parseCustomEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nArray\u003cEmoji\u003e\n```\n\n**\\_parseAnimatedCustomEmojis** - *Used internally by the library*\n\nParses the animated custom emojis from a string.\n```js\nEmojiParser._parseAnimatedCustomEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nArray\u003cEmoji\u003e\n```\n\n**\\_parseUnicodeEmojis** - *Used internally by the library*\n\nParses the unicode emojis from a string.\n```js\nEmojiParser._parseUnicodeEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nArray\u003cEmoji\u003e\n```\n\n**countEmojis**\n\nCounts the amount of emojis found in a string and returns the numbers.\n```js\nEmojiParser.countEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nObject\n```\n\n**\\_parseEmoji** - *Used internally by the library*\n\nParse the custom emoji, both animated and not, and returns an array of 1 (custom emoji, non animated, it's the emoji's id) or 2 elements (first - an `a` string, specific for animated emojis \u0026 then the second it's the emoji's id).\n```js\nEmojiParser._parseEmoji(\u003cContent - String\u003e);\n```\n- Output:\n```\nArray\u003cString\u003e\n```\n\n**parseEmojis**\n\nParses the string's emojis and returns them in an object, with emojis grouped into 5 properties (`custom`, `customAnimated`, `customEmojis`, `unicode`, `allEmojis`), each of them is an array of emojis. \n```js\nEmojiParser.parseEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nObject\n```\n\n\n## 2. Spoiler Parsing API\n\n**\\_parseSpoilerContent** - *Used internally by the library*\n\nParse a spoiler from end to finnish and returns its contents.\n```js\nSpoilerParser._parseSpoilerContent(\u003cContent - String\u003e);\n```\n- Output:\n```\nString\n```\n\n**parseSpoilers**\n\nParses all of the spoilers in a string and returns them as an array with objects having `content` and `raw` properties.\n```js\nSpoilerMarser.parseEmojis(\u003cContent - String\u003e);\n```\n- Output:\n```\nArray\u003cObject\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodcord%2Fmessage-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodcord%2Fmessage-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodcord%2Fmessage-parser/lists"}