
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@discordjs/rest
Advanced tools
@discordjs/rest
is a module that allows you to easily make REST requests to the Discord API.
Node.js 18 or newer is required.
npm install @discordjs/rest
yarn add @discordjs/rest
pnpm add @discordjs/rest
bun add @discordjs/rest
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);
}
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.
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.
discord.js is a powerful library for interacting with the Discord API. It provides a higher-level abstraction compared to @discordjs/rest, including features for managing WebSocket connections, handling events, and more. While @discordjs/rest focuses on REST API requests, discord.js offers a more comprehensive solution for building Discord bots.
Eris is another library for interacting with the Discord API. It is known for its performance and scalability, making it suitable for large bots. Like discord.js, Eris provides a higher-level abstraction and includes features for managing WebSocket connections and handling events. It also supports REST API requests, similar to @discordjs/rest.
discord-api-types is a package that provides TypeScript typings for the Discord API. While it does not handle REST API requests directly, it can be used in conjunction with @discordjs/rest to ensure type safety and better development experience when working with the Discord API.
FAQs
The REST API for discord.js
The npm package @discordjs/rest receives a total of 248,549 weekly downloads. As such, @discordjs/rest popularity was classified as popular.
We found that @discordjs/rest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.