mirror of
https://github.com/discordjs/discord.js.git
synced 2026-09-17 16:57:28 +00:00
* chore(deps): update github-actions * actions/cache v4 -> v5 * actions/create-github-app-token v2 -> v3 * actions/download-artifact v6 -> v8 * actions/labeler v5 -> v6 * actions/upload-artifact v5 -> v7 * codecov/codecov-action v4 -> v6 * crazy-max/ghaction-github-labeler v5 -> v6 * dessant/lock-threads v5 -> v6 * docker/build-push-action v6 -> v7 * docker/login-action v3 -> v4 * docker/setup-buildx-action v3 -> v4 * pnpm/action-setup v4.1.0 -> v6.0.8 * chore(deps): minor/patch bumps and pnpm v11 * chore(deps): bump lint-staged to v17 * chore(deps): bump commitlint to v21 * chore(deps): bump vercel to v54 * chore(deps): bump vite to v8 * chore(deps): bump chromatic to v17 * chore(deps): bump validate-npm-package-name to v8 * chore(deps): bump uuid to v14 * chore(deps): bump cloudflare to v6 * chore(deps): bump meilisearch to v0.58 * chore(deps): bump fumadocs-mdx to v15 * chore(deps): lockfile * chore: fixes * fixup! chore(deps): minor/patch bumps and pnpm v11 * chore(deps): bump vercel to v56 * chore(deps): bump chromatic to v18 * chore: fix format/lint and change prettier range * chore(deps): bump vitest-websocket-mock to v0.7 * chore(deps): bump cloudflare to v7 * chore(deps): bump meilisearch to v0.59 * chore(deps): bump commander to v15 * chore(deps): bump sharp to v0.35 * chore(deps): bump undici to v8 * chore: lockfile * fixup! chore(deps): update github-actions * fix(rest): requested changes * chore: minor/patch * chore(deps): bump meilisearch to v0.60 * chore(deps): bump vercel to v57 * fixup! fixup! chore(deps): update github-actions * chore: revert prettier upgrade * chore: minor/patch * chore(deps): bump vercel to v58 * chore(deps): regen lockfile * chore(deps): undici 8.10.1 and pnpm 11.25 * chore(deps): minor/patch * fix: lockfile * chore: more
About
@discordjs/rest is a module that allows you to easily make REST requests to the Discord API.
Installation
Node.js 24.17.0 or newer is required.
npm install @discordjs/rest
yarn add @discordjs/rest
pnpm add @discordjs/rest
bun add @discordjs/rest
Examples
Install all required dependencies:
npm install @discordjs/rest discord-api-types
yarn add @discordjs/rest discord-api-types
pnpm add @discordjs/rest discord-api-types
bun add @discordjs/rest discord-api-types
Send a basic message:
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v10';
const rest = new REST({ version: '10' }).setToken(TOKEN);
try {
await rest.post(Routes.channelMessages(CHANNEL_ID), {
body: {
content: 'A message via REST!',
},
});
} catch (error) {
console.error(error);
}
Create a thread from an existing message to be archived after 60 minutes of inactivity:
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v10';
const rest = new REST({ version: '10' }).setToken(TOKEN);
try {
await rest.post(Routes.threads(CHANNEL_ID, MESSAGE_ID), {
body: {
name: 'Thread',
auto_archive_duration: 60,
},
});
} catch (error) {
console.error(error);
}
Send a basic message in an edge environment:
import { REST } from '@discordjs/rest';
import { Routes } from 'discord-api-types/v10';
const rest = new REST({ version: '10', makeRequest: fetch }).setToken(TOKEN);
try {
await rest.post(Routes.channelMessages(CHANNEL_ID), {
body: {
content: 'A message via REST from the edge!',
},
});
} catch (error) {
console.error(error);
}
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 Developers Discord server
- GitHub
- npm
- Related libraries
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.