{"meta":{"generator":"0.5.2","format":18,"date":1481996700274},"custom":{"general":[{"id":"welcome","name":"Welcome","type":"md","content":"
\n\n# Welcome!\nWelcome to the discord.js v10 documentation.\nv10 is just a more consistent and stable iteration over v9, and contains loads of new and improved features, optimisations, and bug fixes.\n\n## About\ndiscord.js is a powerful node.js module that allows you to interact with the\n[Discord API](https://discordapp.com/developers/docs/intro) very easily.\n\n- Object-oriented\n- Predictable abstractions\n- Performant\n- Nearly 100% coverage of the Discord API\n\n## Installation\n**Node.js 6.0.0 or newer is required.** \nIgnore any warnings about unmet peer dependencies - all of them are optional.\n\nWithout voice support: `npm install discord.js --save` \nWith voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save` \nWith voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript --save`\n\n### Audio engines\nThe preferred audio engine is node-opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose node-opus.\nUsing opusscript is only recommended for development environments where node-opus is tough to get working.\nFor production bots, using node-opus should be considered a necessity, especially if they're going to be running on multiple servers.\n\n### Optional packages\n- [uws](https://www.npmjs.com/package/uws) for much a much faster WebSocket connection (`npm install uws --save`)\n- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack --save`)\n\n## Web distributions\nWeb builds of discord.js that are fully capable of running in browsers are available [here](https://github.com/hydrabolt/discord.js/tree/webpack).\nThese are built by [Webpack 2](https://webpack.js.org/). The API is identical, but rather than using `require('discord.js')`,\nthe entire `Discord` object is available as a global (on the `window` object).\nThe ShardingManager and any voice-related functionality is unavailable in these builds.\n\n## Guides\n* [LuckyEvie's general guide](https://eslachance.gitbooks.io/discord-js-bot-guide/content/)\n* [York's v9 upgrade guide](https://yorkaargh.wordpress.com/2016/09/03/updating-discord-js-bots/)\n\n## Links\n* [Website](https://discord.js.org/)\n* [Discord.js server](https://discord.gg/bRCvFy9)\n* [Discord API server](https://discord.gg/rV4BwdK)\n* [Documentation](https://discord.js.org/#/docs)\n* [Legacy (v8) documentation](http://discordjs.readthedocs.io/en/8.2.0/docs_client.html)\n* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/examples)\n* [GitHub](https://github.com/hydrabolt/discord.js)\n* [NPM](https://www.npmjs.com/package/discord.js)\n* [Related libraries](https://discordapi.com/unofficial/libs.html)\n\n## Help\nIf you don't understand something in the documentation, you are experiencing problems, or you just need a gentle\nnudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).\n"},{"id":"updating","name":"Updating your code","type":"md","content":"# Version 10\nVersion 10's non-BC changes focus on cleaning up some inconsistencies that exist in previous versions.\nUpgrading from v9 should be quick and painless.\n\n## Client options\nAll client options have been converted to camelCase rather than snake_case, and `max_message_cache` was renamed to `messageCacheMaxSize`.\n\nv9 code example:\n```js\nconst client = new Discord.Client({\n disable_everyone: true,\n max_message_cache: 500,\n message_cache_lifetime: 120,\n message_sweep_interval: 60\n});\n```\n\nv10 code example:\n```js\nconst client = new Discord.Client({\n disableEveryone: true,\n messageCacheMaxSize: 500,\n messageCacheLifetime: 120,\n messageSweepInterval: 60\n});\n```\n\n## Presences\nPresences have been completely restructured.\nPrevious versions of discord.js assumed that users had the same presence amongst all guilds - with the introduction of sharding, however, this is no longer the case.\n\nv9 discord.js code may look something like this:\n```js\nUser.status; // the status of the user\nUser.game; // the game that the user is playing\nClientUser.setStatus(status, game, url); // set the new status for the user\n```\n\nv10 moves presences to GuildMember instances. For the sake of simplicity, though, User classes also expose presences.\nWhen accessing a presence on a User object, it simply finds the first GuildMember for the user, and uses its presence.\nAdditionally, the introduction of the Presence class keeps all of the presence data organised.\n\n**It is strongly recommended that you use a GuildMember's presence where available, rather than a User.\nA user may have an entirely different presence between two different guilds.**\n\nv10 code:\n```js\nMemberOrUser.presence.status; // the status of the member or user\nMemberOrUser.presence.game; // the game that the member or user is playing\nClientUser.setStatus(status); // online, idle, dnd, offline\nClientUser.setGame(game, streamingURL); // a game\nClientUser.setPresence(fullPresence); // status and game combined\n```\n\n## Voice\nVoice has been rewritten internally, but in a backwards-compatible manner.\nThere is only one breaking change here; the `disconnected` event was renamed to `disconnect`.\nSeveral more events have been made available to a VoiceConnection, so see the documentation.\n\n## Events\nMany events have been renamed or had their arguments change.\n\n### Client events\n| Version 9 | Version 10 |\n|------------------------------------------------------|-----------------------------------------------|\n| guildMemberAdd(guild, member) | guildMemberAdd(member) |\n| guildMemberAvailable(guild, member) | guildMemberAvailable(member) |\n| guildMemberRemove(guild, member) | guildMemberRemove(member) |\n| guildMembersChunk(guild, members) | guildMembersChunk(members) |\n| guildMemberUpdate(guild, oldMember, newMember) | guildMemberUpdate(oldMember, newMember) |\n| guildRoleCreate(guild, role) | roleCreate(role) |\n| guildRoleDelete(guild, role) | roleDelete(role) |\n| guildRoleUpdate(guild, oldRole, newRole) | roleUpdate(oldRole, newRole) |\n\nThe guild parameter that has been dropped from the guild-related events can still be derived using `member.guild` or `role.guild`.\n\n### VoiceConnection events\n| Version 9 | Version 10 |\n|--------------|------------|\n| disconnected | disconnect |\n\n## Dates and timestamps\nAll dates/timestamps on the structures have been refactored to have a consistent naming scheme and availability.\nAll of them are named similarly to this: \n**Date:** `Message.createdAt` \n**Timestamp:** `Message.createdTimestamp` \nSee the docs for each structure to see which date/timestamps are available on them.\n\n\n# Version 9\nThe version 9 (v9) rewrite takes a much more object-oriented approach than previous versions,\nwhich allows your code to be much more readable and manageable.\nIt's been rebuilt from the ground up and should be much more stable, fixing caching issues that affected\nolder versions. It also has support for newer Discord Features, such as emojis.\n\nVersion 9, while containing a sizable number of breaking changes, does not require much change in your code's logic -\nmost of the concepts are still the same, but loads of functions have been moved around.\nThe vast majority of methods you're used to using have been moved out of the Client class,\ninto other more relevant classes where they belong.\nBecause of this, you will need to convert most of your calls over to the new methods.\n\nHere are a few examples of methods that have changed:\n* `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)`\n * `Client.sendMessage(user, message)` ==> `User.sendMessage(message)`\n* `Client.updateMessage(message, \"New content\")` ==> `Message.edit(\"New Content\")`\n* `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})`\n* `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object)\n* `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()`\n\nA couple more important details:\n* `Client.loginWithToken(\"token\")` ==> `client.login(\"token\")`\n* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`)\n\n## No more callbacks!\nVersion 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed. \nFor example, the following code:\n\n```js\nclient.getChannelLogs(channel, 100, function(messages) {\n console.log(`${messages.length} messages found`);\n});\n```\n\n```js\nchannel.fetchMessages({limit: 100}).then(messages => {\n console.log(`${messages.size} messages found`);\n});\n```\n"},{"id":"faq","name":"FAQ","type":"md","content":"# Frequently Asked Questions\nThese are just questions that get asked frequently, that usually have a common resolution.\nIf you have issues not listed here, please ask in the [official Discord server](https://discord.gg/bRCvFy9).\nAlways make sure to read the documentation.\n\n## No matter what, I get `SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode`‽\nUpdate to Node.js 6.0.0 or newer.\n\n## How do I get voice working?\n- Install FFMPEG.\n- Install either the `node-opus` package or the `opusscript` package.\n node-opus is greatly preferred, due to it having significantly better performance.\n\n## How do I install FFMPEG?\n- **npm:** `npm install --save ffmpeg-binaries`\n- **Ubuntu 16.04:** `sudo apt install ffmpeg`\n- **Ubuntu 14.04:** `sudo apt-get install libav-tools`\n- **Windows:** See the [FFMPEG section of AoDude's guide](https://github.com/bdistin/OhGodMusicBot/blob/master/README.md#download-ffmpeg).\n\n## How do I set up node-opus?\n- **Ubuntu:** Simply run `npm install node-opus`, and it's done. Congrats!\n- **Windows:** Run `npm install --global --production windows-build-tools` in an admin command prompt or PowerShell.\n Then, running `npm install node-opus` in your bot's directory should successfully build it. Woo!\n"}],"examples":[{"id":"ping","name":"Ping","type":"js","content":"/*\n A ping pong bot, whenever you send \"ping\", it replies \"pong\".\n*/\n\n// import the discord.js module\nconst Discord = require('discord.js');\n\n// create an instance of a Discord Client, and call it bot\nconst bot = new Discord.Client();\n\n// the token of your bot - https://discordapp.com/developers/applications/me\nconst token = 'your bot token here';\n\n// the ready event is vital, it means that your bot will only start reacting to information\n// from Discord _after_ ready is emitted.\nbot.on('ready', () => {\n console.log('I am ready!');\n});\n\n// create an event listener for messages\nbot.on('message', message => {\n // if the message is \"ping\",\n if (message.content === 'ping') {\n // send \"pong\" to the same channel.\n message.channel.sendMessage('pong');\n }\n});\n\n// log our bot in\nbot.login(token);\n"},{"id":"avatars","name":"Avatars","type":"js","content":"/*\n Send a user a link to their avatar\n*/\n\n// import the discord.js module\nconst Discord = require('discord.js');\n\n// create an instance of a Discord Client, and call it bot\nconst bot = new Discord.Client();\n\n// the token of your bot - https://discordapp.com/developers/applications/me\nconst token = 'your bot token here';\n\n// the ready event is vital, it means that your bot will only start reacting to information\n// from Discord _after_ ready is emitted.\nbot.on('ready', () => {\n console.log('I am ready!');\n});\n\n// create an event listener for messages\nbot.on('message', message => {\n // if the message is \"what is my avatar\",\n if (message.content === 'what is my avatar') {\n // send the user's avatar URL\n message.reply(message.author.avatarURL);\n }\n});\n\n// log our bot in\nbot.login(token);\n"},{"id":"webhook","name":"Webhook","type":"js","content":"/*\n Send a message using a webhook\n*/\n\n// import the discord.js module\nconst Discord = require('discord.js');\n\n// create a new webhook\nconst hook = new Discord.WebhookClient('webhook id', 'webhook token');\n\n// send a message using the webhook\nhook.sendMessage('I am now alive!');\n"}]},"classes":[{"name":"Client","description":"The starting point for making a Discord Bot.","extends":["EventEmitter"],"construct":{"name":"Client","params":[{"name":"options","description":"Options for the client","optional":true,"type":[[["ClientOptions"]]]}]},"props":[{"name":"options","description":"The options the client was instantiated with","type":[[["ClientOptions"]]],"meta":{"line":34,"file":"Client.js","path":"src/client"}},{"name":"rest","description":"The REST manager of the client","access":"private","type":[[["RESTManager"]]],"meta":{"line":42,"file":"Client.js","path":"src/client"}},{"name":"dataManager","description":"The data manager of the Client","access":"private","type":[[["ClientDataManager"]]],"meta":{"line":49,"file":"Client.js","path":"src/client"}},{"name":"manager","description":"The manager of the Client","access":"private","type":[[["ClientManager"]]],"meta":{"line":56,"file":"Client.js","path":"src/client"}},{"name":"ws","description":"The WebSocket Manager of the Client","access":"private","type":[[["WebSocketManager"]]],"meta":{"line":63,"file":"Client.js","path":"src/client"}},{"name":"resolver","description":"The Data Resolver of the Client","access":"private","type":[[["ClientDataResolver"]]],"meta":{"line":70,"file":"Client.js","path":"src/client"}},{"name":"actions","description":"The Action Manager of the Client","access":"private","type":[[["ActionsManager"]]],"meta":{"line":77,"file":"Client.js","path":"src/client"}},{"name":"voice","description":"The Voice Manager of the Client (`null` in browsers)","access":"private","nullable":true,"type":[[["ClientVoiceManager"]]],"meta":{"line":84,"file":"Client.js","path":"src/client"}},{"name":"shard","description":"The shard helpers for the client (only if the process was spawned as a child, such as from a ShardingManager)","nullable":true,"type":[[["ShardClientUtil"]]],"meta":{"line":90,"file":"Client.js","path":"src/client"}},{"name":"users","description":"A collection of the Client's stored users","type":[[["Collection",".<"],["string",", "],["User",">"]]],"meta":{"line":96,"file":"Client.js","path":"src/client"}},{"name":"guilds","description":"A collection of the Client's stored guilds","type":[[["Collection",".<"],["string",", "],["Guild",">"]]],"meta":{"line":102,"file":"Client.js","path":"src/client"}},{"name":"channels","description":"A collection of the Client's stored channels","type":[[["Collection",".<"],["string",", "],["Channel",">"]]],"meta":{"line":108,"file":"Client.js","path":"src/client"}},{"name":"presences","description":"A collection of presences for friends of the logged in user.\n