[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [devsnek] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncustom: # Replace with a single custom sponsorship URL\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nbrowser.js\n"
  },
  {
    "path": ".npmignore",
    "content": "node_modules\ntest.js\nwebpack.config.js\nREADME.md\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": "README.md",
    "content": "<div align=\"center\">\n  <br />\n  <p>\n    <a href=\"https://discord.gg/bRCvFy9\"><img src=\"https://discordapp.com/api/guilds/222078108977594368/embed.png\" alt=\"Discord server\" /></a>\n    <a href=\"https://www.npmjs.com/package/discord-rich-presence\"><img src=\"https://img.shields.io/npm/v/discord-rich-presence.svg?maxAge=3600\" alt=\"NPM version\" /></a>\n    <a href=\"https://www.npmjs.com/package/discord-rich-presence\"><img src=\"https://img.shields.io/npm/dt/discord-rich-presence.svg?maxAge=3600\" alt=\"NPM downloads\" /></a>\n    <a href=\"https://david-dm.org/devsnek/discord-rich-presence\"><img src=\"https://img.shields.io/david/devsnek/discord-rich-presence.svg?maxAge=3600\" alt=\"Dependencies\" /></a>\n  </p>\n  <p>\n    <a href=\"https://nodei.co/npm/discord-rich-presence/\"><img src=\"https://nodei.co/npm/discord-rich-presence.png?downloads=true&stars=true\" alt=\"NPM info\" /></a>\n  </p>\n</div>\n\n# Discord Rich Presence\n\nA simple wrapper around [discord-rpc](https://npmjs.org/discord-rpc)\n\n### Example\n\n```javascript\nconst client = require('discord-rich-presence')('180984871685062656');\n\nclient.updatePresence({\n  state: 'slithering',\n  details: '🐍',\n  startTimestamp: Date.now(),\n  endTimestamp: Date.now() + 1337,\n  largeImageKey: 'snek_large',\n  smallImageKey: 'snek_small',\n  instance: true,\n});\n```\n\nIn browser you can import/require it as `discord-rich-presence/browser`.\nHowever, it should be noted that currently using rich presence in browser is\na feature whitelisted by Discord, and you will most likely be unable to use it.\n"
  },
  {
    "path": "index.js",
    "content": "'use strict';\n\nconst Discord = require('discord-rpc');\nconst EventEmitter = require('events');\n\nconst browser = typeof window !== 'undefined';\n\nfunction makeClient(clientId) {\n  const rpc = new Discord.Client({ transport: browser ? 'websocket' : 'ipc' });\n\n  let connected = false;\n  let activityCache = null;\n\n  const instance = new class RP extends EventEmitter {\n    updatePresence(d) {\n      if (connected) {\n        rpc.setActivity(d).catch((e) => this.emit('error', e));\n      } else {\n        activityCache = d;\n      }\n    }\n\n    reply(user, response) {\n      const handle = (e) => this.emit('error', e);\n      switch (response) {\n        case 'YES':\n          rpc.sendJoinInvite(user).catch(handle);\n          break;\n        case 'NO':\n        case 'IGNORE':\n          rpc.closeJoinRequest(user).catch(handle);\n          break;\n        default:\n          throw new RangeError('unknown response');\n      }\n    }\n\n    disconnect() {\n      rpc.destroy().catch((e) => this.emit('error', e));\n    }\n  }();\n\n  rpc.on('error', (e) => instance.emit('error', e));\n\n  rpc.login({ clientId })\n    .then(() => {\n      instance.emit('connected');\n      connected = true;\n\n      rpc.subscribe('ACTIVITY_JOIN', ({ secret }) => {\n        instance.emit('join', secret);\n      });\n      rpc.subscribe('ACTIVITY_SPECTATE', ({ secret }) => {\n        instance.emit('spectate', secret);\n      });\n      rpc.subscribe('ACTIVITY_JOIN_REQUEST', (user) => {\n        instance.emit('joinRequest', user);\n      });\n\n      if (activityCache) {\n        rpc.setActivity(activityCache).catch((e) => instance.emit('error', e));\n        activityCache = null;\n      }\n    })\n    .catch((e) => instance.emit('error', e));\n\n  return instance;\n}\n\nmodule.exports = makeClient;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"discord-rich-presence\",\n  \"version\": \"0.0.8\",\n  \"description\": \"rich presence wrapper for discord-rpc\",\n  \"main\": \"index.js\",\n  \"unpkg\": \"browser.js\",\n  \"jsdelivr\": \"browser.js\",\n  \"scripts\": {\n    \"build:browser\": \"webpack\",\n    \"prepublishOnly\": \"env NODE_ENV=production npm run build:browser\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/devsnek/discord-rich-presence.git\"\n  },\n  \"keywords\": [\n    \"discord\",\n    \"rich\",\n    \"presence\",\n    \"rpc\"\n  ],\n  \"author\": \"snek <me@gus.host>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/devsnek/discord-rich-presence/issues\"\n  },\n  \"homepage\": \"https://github.com/devsnek/discord-rich-presence#readme\",\n  \"dependencies\": {\n    \"discord-rpc\": \"github:discordjs/rpc\"\n  },\n  \"devDependencies\": {\n    \"uglifyjs-webpack-plugin\": \"^1.1.2\",\n    \"webpack\": \"^3.10.0\"\n  }\n}\n"
  },
  {
    "path": "test.js",
    "content": "'use strict';\n\nconst client = require('.')('180984871685062656');\n\nclient.on('join', (secret) => {\n  console.log('we should join with', secret);\n});\n\nclient.on('spectate', (secret) => {\n  console.log('we should spectate with', secret);\n});\n\nclient.on('joinRequest', (user) => {\n  if (user.discriminator === '1337') {\n    client.reply(user, 'YES');\n  } else {\n    client.reply(user, 'IGNORE');\n  }\n});\n\nclient.on('connected', () => {\n  console.log('connected!');\n\n  client.updatePresence({\n    state: 'slithering',\n    details: '🐍',\n    startTimestamp: new Date(),\n    largeImageKey: 'snek_large',\n    smallImageKey: 'snek_small',\n    partyId: 'snek_party',\n    partySize: 1,\n    partyMax: 1,\n    matchSecret: 'slithers',\n    joinSecret: 'boop',\n    spectateSecret: 'sniff',\n  });\n});\n\nprocess.on('unhandledRejection', console.error);\n"
  },
  {
    "path": "webpack.config.js",
    "content": "const path = require('path');\nconst webpack = require('webpack');\nconst UglifyJSPlugin = require('uglifyjs-webpack-plugin');\n\nconst plugins = [\n  new webpack.optimize.ModuleConcatenationPlugin(),\n];\n\nconst prod = process.env.NODE_ENV === 'production';\n\nif (prod) {\n  plugins.push(new UglifyJSPlugin({\n    uglifyOptions: {\n      mangle: { keep_classnames: true },\n      output: { comments: false },\n    },\n  }));\n}\n\nmodule.exports = {\n  entry: './index.js',\n  output: {\n    path: path.resolve('.'),\n    filename: 'browser.js',\n    library: 'DiscordRichPresence',\n    libraryTarget: 'umd',\n  },\n  module: {\n    rules: [\n      { test: /\\.md$/, loader: 'ignore-loader' },\n    ],\n  },\n  node: {\n    fs: 'empty',\n    dns: 'empty',\n    tls: 'empty',\n    child_process: 'empty',\n    dgram: 'empty',\n    __dirname: true,\n    process: false,\n    path: 'empty',\n    Buffer: false,\n    zlib: 'empty',\n  },\n  plugins,\n};\n"
  }
]