mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
* feat: inital user-installable apps support * docs: add deprecation warnings * feat: add equality checks * fix: possibly `null` cases * docs: tweaks * docs: add deprecations * fix(ApplicationCommandManager): amend transform command * feat: properly support `integration_types_config` * docs: add . * docs: minor changes * featBaseApplicationCommandData): update type * style: prettier * chore: fix issues * fix: correct casing Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> * refactor: remove console log * fix: use case that satisfies `/core` and the API * fix: `oauth2InstallParams` property is not nullable * fix: do not convert keys into strings * feat: update transforer to return the full map * feat: update transformers * feat: add `PartialGroupDMMessageManager ` Hope this is not a breaking change * docs: fix type * feat: add approximate count of users property * fix: messageCreate doesn't emit in PartialGroupDMChannel * fix: add GroupDM to TextBasedChannelTypes * feat: add NonPartialGroupDMChannel helper * fix: expect PartialGroupDMChannel * feat: narrow generic type * test: exclude PartialGroupDMChannel * feat: use structure's channel type * docs: narrow type * feat: remove transformer * refactor: remove unnecessary parse * feat: add APIAutoModerationAction transformer * fix: use the right transformer during recursive parsing of interaction metadata * docs: add external types * docs: add `Message#interactionMetadata` property docs * docs: make nullable * docs: add d-docs link * docs: use optional * fix: make `oauth2InstallParams` nullable * types: update `IntegrationTypesConfiguration` Co-authored-by: Almeida <github@almeidx.dev> * docs: update `IntegrationTypesConfigurationParameters` Co-authored-by: Almeida <github@almeidx.dev> * types: update `IntegrationTypesConfigurationParameters` * refactor: improve readability * docs: mark integrationTypesConfig nullable * refactor: requested changes --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Co-authored-by: Vlad Frangu <me@vladfrangu.dev> Co-authored-by: Almeida <github@almeidx.dev>
About
discord.js is a powerful Node.js module that allows you to easily interact with the Discord API.
- Object-oriented
- Predictable abstractions
- Performant
- 100% coverage of the Discord API
Installation
Node.js 16.11.0 or newer is required.
npm install discord.js
yarn add discord.js
pnpm add discord.js
bun add discord.js
Optional packages
- zlib-sync for WebSocket data compression and inflation (
npm install zlib-sync) - bufferutil for a much faster WebSocket connection (
npm install bufferutil) - utf-8-validate in combination with
bufferutilfor much faster WebSocket processing (npm install utf-8-validate) - @discordjs/voice for interacting with the Discord Voice API (
npm install @discordjs/voice)
Example usage
Install discord.js:
npm install discord.js
yarn add discord.js
pnpm add discord.js
bun add discord.js
Register a slash command against the Discord API:
import { REST, Routes } from 'discord.js';
const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];
const rest = new REST({ version: '10' }).setToken(TOKEN);
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
Afterwards we can create a quite simple example bot:
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login(TOKEN);
Links
- Website (source)
- Documentation
- Guide (source) Also see the v13 to v14 Update Guide, which includes updated and removed items from the library.
- discord.js Discord server
- Discord API Discord server
- GitHub
- npm
- Related libraries
Extensions
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
documentation.
See the contribution guide if you'd like to submit a PR.
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.