{"_id":"@deathinside/discord-mentions-js","_rev":"2-da8f6e2b1a3cf718ef63046f6326e3f6","name":"@deathinside/discord-mentions-js","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@deathinside/discord-mentions-js","version":"1.0.1","description":"Easily extract a member, role, or channel from a Discord mention.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/alsheikhaminulislam/discord-mentions-js.git"},"keywords":["discord","discord.js","mention","mentions"],"author":{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"},"license":"ISC","dependencies":{"discord.js":"^12.5.1"},"publishConfig":{"access":"public"},"gitHead":"ba9988dff39e881b187280f652961bb6e41a8483","bugs":{"url":"https://github.com/alsheikhaminulislam/discord-mentions-js/issues"},"homepage":"https://github.com/alsheikhaminulislam/discord-mentions-js#readme","_id":"@deathinside/discord-mentions-js@1.0.1","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-c1EmngHvFBPI9AikfiZ1B7DNG/Ggx9boEvkqark6+mPsHxiv1H7penYwbDwSj7khlaN5fVuPOB0OyvwiVLp+Eg==","shasum":"c1398b5c07eb6f2cec8e820f6cb8b70e4b8989c5","tarball":"https://registry.npmjs.org/@deathinside/discord-mentions-js/-/discord-mentions-js-1.0.1.tgz","fileCount":4,"unpackedSize":136374,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPxtCCRA9TVsSAnZWagAAGmQP/ivvadSSyubQxrDQeNrL\nIuMxfuD2RpPJmq2PqqmWEUPAWfbxXT0K8OvYQc1jEgSA+1rOzcJU0iLDrHFm\n4GsnonvqwWpbEvXxVbOhKs007ndLOxbqfNxzt4DXv54qP5j7yji8Lyan83lQ\no3SiYhStQiebcD1G6gIZYMlcfErc0ouLlkJwnJfXpfGDnn7rcMseht9nkA8i\ndTJv7Tvzs8e63SxdrsHxQDcsD87l8l0FxGIx1BjlMDhn8+zqf4smuhhFjjdU\nIvgsinidPl9d9tpEUG++02xi5VIMpT96NsxszNhs+GzYRUzFVTG0/YBs0cFp\nb6malmrRqvnmbwie/3ApCa3yowMv7jLSHw1HN5oum2KXffef+pPJrYKwcuwc\nhj1Qqkl26GwSfvWGdVUpeOvkesAJljXDsWOawLZNxWWxqJJJSWCUgNkveSU+\n/pVQT2qJcTc7WPqs3bF7zoQsfFrm64xp0fVDnnCBhLeBHYBbOSzJWmjOIYba\nppoYoncQ9u9yxx6jc8KriJUuG0jcsHgbkyMtPB+4TCHDgZtsV/CSw0iVRFUH\naTZjzxsX3EUmbRQDc3Ej7GdLBdbnqLtHv/iuX0XecFLdHVc294Uckqcn1Fd6\nFINEOGRL1kUD9xby3kFnE693ZRKQCpB6zrbEYOwMgQnJ0sdXFlSRQqfrQmfp\n3oyB\r\n=VOGv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFTwu+lotciUSKoNjNTc+viex4LrVKuD/hdwZ563vfnTAiARl7taZCaVYm1WN2qijIneVxIr2up4cZhNt7t0g9fT8w=="}]},"_npmUser":{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"},"directories":{},"maintainers":[{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/discord-mentions-js_1.0.1_1614748481912_0.39270037722119544"},"_hasShrinkwrap":false},"1.0.2":{"name":"@deathinside/discord-mentions-js","version":"1.0.2","description":"Easily extract a member, role, or channel from a Discord mention.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/alsheikhaminulislam/discord-mentions-js.git"},"keywords":["discord","discord.js","mention","mentions"],"author":{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"},"license":"ISC","dependencies":{"discord.js":"^12.5.1"},"publishConfig":{"access":"public"},"bugs":{"url":"https://github.com/alsheikhaminulislam/discord-mentions-js/issues"},"homepage":"https://github.com/alsheikhaminulislam/discord-mentions-js#readme","_id":"@deathinside/discord-mentions-js@1.0.2","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-Q2OqElGdFKvuP8UjTDEx9oeX471LpdfsMxuT6x5krXvR7G+H/xPgyGHWH7bnxo9SMQ5dbBasuVq/y/CrDXBDwg==","shasum":"af9287de4d09d6d027ea87ea799a24fe1593e3a1","tarball":"https://registry.npmjs.org/@deathinside/discord-mentions-js/-/discord-mentions-js-1.0.2.tgz","fileCount":4,"unpackedSize":136283,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPyM0CRA9TVsSAnZWagAAy74P/jqE4+PrETnEysY9KZSp\nXY2luFPWeb85umQfqizfR6ogQtyDCx3vaEuw5QnojKCEHHha/T0gCsmUlOlq\nQBF6LzfDzYPrKq3vpt/j2tRsvWsAWw2XOf9xG0O1TZA5gAG30uWApYK4lt6y\nNRJPAXX2pbymLsGixknxNky3kTEYTN+zm85OMJ1Mx3k+CHo3q+RBFK7gZ2MJ\n7ThWEbhE4fJsASy5v2wx5yIHjRa1PrSqdnqtdn5reIbQTplI/kTsMEBCVIUa\naBeqEp3wkrbsQryXupKKF6gipnj7Rd1y5KvKyQXU1ZfWrmIIcbF9J9nYUPDq\nMLPNvTrwYkFUBkB1mUsuGQsZdhwi2a0dOV3zvqz4i9hda/ePV3RMDAFY1C3i\n0ugsPF+fv/qZi/bDLCVnuYhQkxGekqXj/2PW9ADQ9yvj487IPRGAwBu6izzr\nuNw8H/VzXBGpPYadiC6cgEicwigf6SO3axXdWD0UgoMMbNgaTU8OBUf/a6uo\n6eZ0RJEUCzGgd2DKktZpw6lv3Z6yiLFoKltKVf9RKW+EqWGr5fzhyILwgLQU\nhCWxB6jUhC6Brhifxc+QaF6yvlrqEPSFrTD3nkQqD+h54PETVz9wmQvGgr3P\ndvJHclST42k3KOVb7ewHi8NOaMTdT39/fYIuDRxl46XOQrPSd+mJBMWTBaiR\nc6Rm\r\n=HOup\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDrR3GruEXlT9KHt0L1qgEcaPCp+yaV5HtvkCbfpgAyZwIgSRFSb/bQx3NUgVVoOuohINQ2RQrndWwAndLhiap4nLU="}]},"_npmUser":{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"},"directories":{},"maintainers":[{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/discord-mentions-js_1.0.2_1614750516408_0.7301055969750947"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-03T05:14:41.665Z","1.0.1":"2021-03-03T05:14:42.068Z","modified":"2022-04-05T03:28:36.112Z","1.0.2":"2021-03-03T05:48:36.594Z"},"maintainers":[{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"}],"description":"Easily extract a member, role, or channel from a Discord mention.","homepage":"https://github.com/alsheikhaminulislam/discord-mentions-js#readme","keywords":["discord","discord.js","mention","mentions"],"repository":{"type":"git","url":"git+https://github.com/alsheikhaminulislam/discord-mentions-js.git"},"author":{"name":"alsheikhaminulislam","email":"alsheikhaminulislam@gmail.com"},"bugs":{"url":"https://github.com/alsheikhaminulislam/discord-mentions-js/issues"},"license":"ISC","readme":"<p align=\"center\">\n    <a href=\"https://github.com/slothiful/discord-mentions\"><img width=\"250\" height=\"62.5\" src=\"https://github.com/slothiful/discord-mentions/blob/master/logo.png?raw=true\"></a>\n</p>\n<p align=\"center\">\n    <a href=\"https://www.npmjs.com/package/discord-mentions\"><img src=\"https://img.shields.io/npm/v/discord-mentions.svg\"></a>\n    <a href=\"https://bundlephobia.com/result?p=discord-mentions@3.2.0\"><img src=\"https://img.shields.io/bundlephobia/min/discord-mentions.svg\"></a>\n    <a href = \"https://github.com/slothiful/discord-mentions/issues\"><img src=\"https://img.shields.io/github/issues/slothiful/discord-mentions.svg\"></a>\n</p>\n\n## About\nEasily extract a member, role, or channel from a Discord mention using [Discord.js](https://www.npmjs.com/package/discord.js).\n\n## Usage\n```js\nconst getMention = require('@deathinside/discord-mentions-js');\n\nvar member = getMention('<@!189855563893571595>', someGuild).member;\n// Expected: GuildMember\n\nvar role = getMention('<@&12345689012345678>', someGuild).role;\n// Expected: '12345689012345678' (ID doesn't refer to a valid role)\n\nvar id = getMention('<#632684617312370698>').channel;\n// Expected: '632684617312370698'\n\nvar mention = getMention('not a mention');\n// Expected: null\n```\nReturns...\n* **...when a valid mention and guild are provided:**  \n    an object with a `member`, `role`, or `channel` property as the mentioned GuildMember/Role/GuildChannel.\n    \n* **...when a valid mention is provided, but the guild parameter is omitted:**  \n    an object with a `member`, `role`, or `channel` property as the ID inside the mention.\n    \n* **...when an invalid mention and valid guild are provided:**  \n    an object with a `member`, `role`, or `channel` property as as the ID inside the mention.\n    \n* **...when an invalid mention is provided, but the guild parameter is omitted:**  \n    `null`\n\n## Example\nUsing the client's mention as its prefix and implementing a command which requires a mentioned recipient...\n```js\nconst getMention = require('discord-mentions');\n\nclient.on('message', message => {\n  if (!message.guild || message.author.bot) return;\n  \n  const args = message.content.trim().split(/\\s+/g);\n  \n  // Ignoring the message if it doesn't start with the client's mention.\n  if (getMention(args[0]) !== client.user.id) return;\n  \n  args.shift();\n  const cmd = args[0].toLowerCase();\n  \n  // Simple hug command - mention a member to hug. This is where\n  // 'message.mentions.members.first()' won't help, since it's\n  // actually the client every time with this setup.\n  if (cmd === 'hug') {\n    try {\n      // Making sure the first argument is a mention.\n      const mention = getMention(args[1], message.guild);\n      if (!mention) return await message.channel.send(':x: Please mention a member to hug.');\n      \n      // Making sure the mention is a member.\n      const recipient = mention.member;\n      if (!recipient || typeof recipient === 'string') return await message.channel.send(':x: That\\'s a mention, but not a member!');\n      \n      await message.channel.send(`${message.author} hugs ${recipient}!`);\n    } catch(err) {\n      console.error(err);\n    }\n  }\n});\n```\n","readmeFilename":"README.md"}