mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 08:03:30 +01:00
a51ddb2b06d1b5ba03f18776457e842747c1de44
* fix(Message#editable): update editable check in threads locked (#9216) * fix(Message#editable): update editable check in threads locked * fix(Message#editable): add check in archived threads * fix: check manage threads permission only if thread is locked * fix: adding a full stop at the end of a sentence Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com> --------- Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> * fix(ThreadManager): Respect `cache` and `force` in fetching (#9239) * fix(ThreadManager): Respect `cache` and `force` in fetching * refactor: remove defaults These are already defaulted down the line. --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * refactor(FetchThreadsOptions): Remove `active` (#9241) * refactor(FetchThreadsOptions): remove `active` * docs(FetchThreadsOptions): update description --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * docs: add more examples (#9252) * docs: add more examples * fix: fix grammar and syntax Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com> * chore: fine-tune examples * chore: replace double quotes with singles * fix: remove redundant example tag * fix: fix timeout logging * Update packages/discord.js/src/structures/GuildMember.js Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --------- Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * docs(Role): Fix example for `comparePositionTo()` * docs(FetchArchivedThreadOptions): `before` respects `archive_timestamp`, not creation timestamp (#9240) docs(FetchArchivedThreadOptions): correct `before` description Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(snowflake): snowflakes length (#9144) * fix(snowflake): fix snowflakes length * fix(snowflake): fix length * fix(Message): `bulkDeletable` permissions should be retrieved later for DMs (#9146) * fix(Message): permissions check should be done later the getter will error if used on a message originating from a DM * refactor: remove unessercary chaining * fix: invalid backport Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> * docs(Role): fix comparison example * fix(ClientUser): no mutation on edit * refactor: call bans.create directly * fix(AutocompleteInteraction): Send `name_localizations` correctly (#9238) fix(AutocompleteInteraction): send locale correctly Co-authored-by: space <spaceeec@yahoo.com> * fix: resolving string bitfield (#9262) fix: resolving bitfield Co-authored-by: space <spaceeec@yahoo.com> * fix: Keep symbols in actions manager (#9293) fix: keep symbols in actions manager * fix: add support for new guild feature `GUILD_WEB_PAGE_VANITY_URL` (#9219) Co-authored-by: space <spaceeec@yahoo.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * docs: differ `User#send` (#9251) * docs: differate user#send * chore: format * chore: remove some examples * docs: add GuildMember#send example --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * docs: describe private properties (#8879) * feat: describe private properties * Update packages/discord.js/src/structures/GuildMember.js Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> * Apply suggestions from code review --------- Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --------- Co-authored-by: Erwan <erwan977@gmail.com> Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Tetie <tjvssr@gmail.com> Co-authored-by: DraftMan <contact@draftman.fr> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: Jaw0r3k <jaw0r3k.g@gmail.com> Co-authored-by: space <spaceeec@yahoo.com> Co-authored-by: pkdev08 <54294685+pkdev08@users.noreply.github.com> Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>
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.6.0 or newer is required.
npm install discord.js
yarn add discord.js
pnpm add discord.js
Optional packages
- zlib-sync for WebSocket data compression and inflation (
npm install zlib-sync) - erlpack for significantly faster WebSocket data (de)serialisation (
npm install discord/erlpack) - 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 all required dependencies:
npm install discord.js @discordjs/rest discord-api-types
yarn add discord.js @discordjs/rest discord-api-types
pnpm add discord.js @discordjs/rest discord-api-types
Register a slash command against the Discord API:
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const commands = [{
name: 'ping',
description: 'Replies with Pong!'
}];
const rest = new REST({ version: '9' }).setToken('token');
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
Afterwards we can create a quite simple example bot:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login('token');
Links
- Website (source)
- Documentation
- Guide (source) See also the Update Guide, including updated and removed items in 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.
Description
Languages
TypeScript
61.1%
JavaScript
28.5%
MDX
10.1%
CSS
0.2%