README.md (5253B)
1 <div align="center"> 2 <br /> 3 <p> 4 <a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a> 5 </p> 6 <br /> 7 <p> 8 <a href="https://discord.gg/bRCvFy9"><img src="https://discordapp.com/api/guilds/222078108977594368/embed.png" alt="Discord server" /></a> 9 <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="NPM version" /></a> 10 <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" /></a> 11 <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/workflows/Testing/badge.svg" alt="Build status" /></a> 12 <a href="https://david-dm.org/discordjs/discord.js"><img src="https://img.shields.io/david/discordjs/discord.js.svg?maxAge=3600" alt="Dependencies" /></a> 13 <a href="https://www.patreon.com/discordjs"><img src="https://img.shields.io/badge/donate-patreon-F96854.svg" alt="Patreon" /></a> 14 </p> 15 <p> 16 <a href="https://nodei.co/npm/discord.js/"><img src="https://nodei.co/npm/discord.js.png?downloads=true&stars=true" alt="npm installnfo" /></a> 17 </p> 18 </div> 19 20 ## Table of contents 21 22 - [About](#about) 23 - [Installation](#installation) 24 - [Audio engines](#audio-engines) 25 - [Optional packages](#optional-packages) 26 - [Example Usage](#example-usage) 27 - [Links](#links) 28 - [Extensions](#extensions) 29 - [Contributing](#contributing) 30 - [Help](#help) 31 32 ## About 33 34 discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the 35 [Discord API](https://discordapp.com/developers/docs/intro). 36 37 - Object-oriented 38 - Predictable abstractions 39 - Performant 40 - 100% coverage of the Discord API 41 42 ## Installation 43 44 **Node.js 12.0.0 or newer is required.** 45 Ignore any warnings about unmet peer dependencies, as they're all optional. 46 47 Without voice support: `npm install discord.js` 48 With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)): `npm install discord.js @discordjs/opus` 49 With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript` 50 51 ### Audio engines 52 53 The preferred audio engine is @discordjs/opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose @discordjs/opus. 54 Using opusscript is only recommended for development environments where @discordjs/opus is tough to get working. 55 For production bots, using @discordjs/opus should be considered a necessity, especially if they're going to be running on multiple servers. 56 57 ### Optional packages 58 59 - [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`) 60 - [erlpack](https://github.com/discordapp/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install discordapp/erlpack`) 61 - One of the following packages can be installed for faster voice packet encryption and decryption: 62 - [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) 63 - [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) 64 - [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`) 65 - [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`) 66 67 ## Example usage 68 69 ```js 70 const Discord = require('discord.js'); 71 const client = new Discord.Client(); 72 73 client.on('ready', () => { 74 console.log(`Logged in as ${client.user.tag}!`); 75 }); 76 77 client.on('message', msg => { 78 if (msg.content === 'ping') { 79 msg.reply('pong'); 80 } 81 }); 82 83 client.login('token'); 84 ``` 85 86 ## Links 87 88 - [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) 89 - [Documentation](https://discord.js.org/#/docs/main/master/general/welcome) 90 - [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) - this is still for stable 91 See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v12.html), including updated and removed items in the library. 92 - [Discord.js Discord server](https://discord.gg/bRCvFy9) 93 - [Discord API Discord server](https://discord.gg/discord-api) 94 - [GitHub](https://github.com/discordjs/discord.js) 95 - [NPM](https://www.npmjs.com/package/discord.js) 96 - [Related libraries](https://discordapi.com/unofficial/libs.html) 97 98 ### Extensions 99 100 - [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) 101 102 ## Contributing 103 104 Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the 105 [documentation](https://discord.js.org/#/docs). 106 See [the contribution guide](https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR. 107 108 ## Help 109 110 If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle 111 nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).