- Javascript discord desktop core
- Installation
- Example usage
- Independent REST API Usage
- Links
- Contributing
- Help
- Javascript discord desktop core
- Installation
- Example usage
- Independent REST API Usage
- Links
- Contributing
- Help
- Saved searches
- Use saved searches to filter your results more quickly
- License
- discordjs/discord.js
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Javascript discord desktop core
@discordjs/core is a thinly abstracted wrapper around the «core» components of the Discord API: REST, and gateway.
Installation
Node.js 16.9.0 or newer is required.
npm install @discordjs/core
yarn add @discordjs/core
pnpm add @discordjs/core
npm install @discordjs/core
yarn add @discordjs/core
pnpm add @discordjs/core
Example usage
import from '@discordjs/rest';
import from '@discordjs/ws';
import from '@discordjs/core';
// Create REST and WebSocket managers directly
const rest = new REST(< version: '10' >).setToken(process.env.DISCORD_TOKEN);
const gateway = new WebSocketManager(
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
>);
// Create a client to emit relevant events.
const client = new Client(< rest, gateway >);
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
client.on(GatewayDispatchEvents.InteractionCreate, async ( data: interaction, api >) =>
if (interaction.type !== InteractionType.ApplicationCommand || interaction.data.name !== 'ping')
return;
>
await api.interactions.reply(interaction.id, interaction.token, < content: 'Pong!', flags: MessageFlags.Ephemeral >);
>);
// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
import from '@discordjs/rest';
import from '@discordjs/ws';
import < GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client > from '@discordjs/core';
// Create REST and WebSocket managers directly
const rest = new REST(< version: '10' >).setToken(process.env.DISCORD_TOKEN);
const gateway = new WebSocketManager(
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
>);
// Create a client to emit relevant events.
const client = new Client(< rest, gateway >);
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
client.on(GatewayDispatchEvents.InteractionCreate, async (< data: interaction, api >) =>
if (interaction.type !== InteractionType.ApplicationCommand || interaction.data.name !== 'ping')
return;
>
await api.interactions.reply(interaction.id, interaction.token, < content: 'Pong!', flags: MessageFlags.Ephemeral >);
>);
// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
Independent REST API Usage
// Create REST instance
const rest = new REST(< version: '10' >).setToken(token);
// Pass into API
const api = new API(rest);
// Fetch a guild using the API wrapper
const guild = await api.guilds.get('1234567891011');
// Create REST instance
const rest = new REST(< version: '10' >).setToken(token);
// Pass into API
const api = new API(rest);
// Fetch a guild using the API wrapper
const guild = await api.guilds.get('1234567891011');
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
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.
Javascript discord desktop core
@discordjs/core is a thinly abstracted wrapper around the «core» components of the Discord API: REST, and gateway.
Installation
Node.js 16.9.0 or newer is required.
npm install @discordjs/core
yarn add @discordjs/core
pnpm add @discordjs/core
npm install @discordjs/core
yarn add @discordjs/core
pnpm add @discordjs/core
Example usage
import from '@discordjs/rest';
import from '@discordjs/ws';
import from '@discordjs/core';
// Create REST and WebSocket managers directly
const rest = new REST(< version: '10' >).setToken(process.env.DISCORD_TOKEN);
const gateway = new WebSocketManager(
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
>);
// Create a client to emit relevant events.
const client = new Client(< rest, gateway >);
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
client.on(GatewayDispatchEvents.InteractionCreate, async ( data: interaction, api >) =>
if (interaction.type !== InteractionType.ApplicationCommand || interaction.data.name !== 'ping')
return;
>
await api.interactions.reply(interaction.id, interaction.token, < content: 'Pong!', flags: MessageFlags.Ephemeral >);
>);
// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
import from '@discordjs/rest';
import from '@discordjs/ws';
import < GatewayDispatchEvents, GatewayIntentBits, InteractionType, MessageFlags, Client > from '@discordjs/core';
// Create REST and WebSocket managers directly
const rest = new REST(< version: '10' >).setToken(process.env.DISCORD_TOKEN);
const gateway = new WebSocketManager(
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
>);
// Create a client to emit relevant events.
const client = new Client(< rest, gateway >);
// Listen for interactions
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
client.on(GatewayDispatchEvents.InteractionCreate, async (< data: interaction, api >) =>
if (interaction.type !== InteractionType.ApplicationCommand || interaction.data.name !== 'ping')
return;
>
await api.interactions.reply(interaction.id, interaction.token, < content: 'Pong!', flags: MessageFlags.Ephemeral >);
>);
// Listen for the ready event
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
// Start the WebSocket connection.
gateway.connect();
Independent REST API Usage
// Create REST instance
const rest = new REST(< version: '10' >).setToken(token);
// Pass into API
const api = new API(rest);
// Fetch a guild using the API wrapper
const guild = await api.guilds.get('1234567891011');
// Create REST instance
const rest = new REST(< version: '10' >).setToken(token);
// Pass into API
const api = new API(rest);
// Fetch a guild using the API wrapper
const guild = await api.guilds.get('1234567891011');
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
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.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A powerful JavaScript library for interacting with the Discord API
License
discordjs/discord.js
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
* refactor(REST): remove double classing BREAKING CHANGE: `REST` and `RequestManager` have been combined, most of the properties, methods, and events from both classes can now be found on `REST` BREAKING CHANGE: `REST#raw` has been removed in favor of `REST#queueRequest` BREAKING CHANGE: `REST#getAgent` has been removed in favor of `REST#agent` * chore: update for /rest changes
Git stats
Files
Failed to load latest commit information.
README.md
This repository contains multiple packages with separate releases. You can find the assembled Discord API wrapper at discord.js . It is a powerful Node.js module that allows you to easily interact with the Discord API.
- discord.js (source) — A powerful Node.js module for interacting with the Discord API
- @discordjs/brokers (source) — A collection of brokers for use with discord.js
- @discordjs/builders (source) — A utility package for easily building Discord API payloads
- @discordjs/collection (source) — A powerful utility data structure
- @discordjs/core (source) — A thinly abstracted wrapper around the core components of the Discord API
- @discordjs/formatters (source) — A collection of functions for formatting strings
- @discordjs/proxy (source) — A wrapper around @discordjs/rest for running an HTTP proxy
- @discordjs/rest (source) — A module for interacting with the Discord REST API
- @discordjs/voice (source) — A module for interacting with the Discord Voice API
- @discordjs/util (source) — A collection of utility functions
- @discordjs/ws (source) — A wrapper around Discord’s gateway
- 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
Please read through our contribution guidelines before starting a pull request. We welcome contributions of all kinds, not just code! If you’re stuck for ideas, look for the good first issue label on issues in the repository. If you have any questions about the project, feel free to ask them on Discord. Before creating your own issue or pull request, always check to see if one already exists! Don’t rush contributions, take your time and ensure you’re doing it correctly.
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 join our Discord server.
About
A powerful JavaScript library for interacting with the Discord API