14.14.1-2 • Published 10 days ago

@draftbot/discord.js v14.14.1-2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 days ago

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 bufferutil for much faster WebSocket processing (npm install utf-8-validate)
  • @draftbot/voice for interacting with the Discord Voice API (npm install @draftbot/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

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.

14.14.1-2

10 days ago

14.14.1-1

10 days ago

14.14.1

11 days ago

14.9.0-23

4 months ago

14.9.0-18

10 months ago

14.9.0-19

8 months ago

14.9.0-20

8 months ago

14.9.0-21

8 months ago

14.9.0-22

7 months ago

14.6.0-4

1 year ago

14.6.0-5

1 year ago

14.6.0-6

1 year ago

14.6.0-7

1 year ago

14.6.0-3

1 year ago

14.6.0-8

1 year ago

14.6.0-9

1 year ago

14.9.0-4-c

1 year ago

14.6.0-10

1 year ago

14.6.0-13

1 year ago

14.6.0-14

1 year ago

14.6.0-11

1 year ago

14.6.0-12

1 year ago

14.9.0-14

11 months ago

14.9.0-15

11 months ago

14.9.0-16

11 months ago

14.9.0-17

10 months ago

14.7.1-4

1 year ago

14.7.1-5

1 year ago

14.7.1-2

1 year ago

14.7.1-3

1 year ago

14.7.1-1

1 year ago

14.7.1-6

1 year ago

14.7.1-7

1 year ago

14.8.0-1

1 year ago

14.8.0-2

1 year ago

14.9.0-7

11 months ago

14.9.0-8

11 months ago

14.9.0-5

1 year ago

14.9.0-6

11 months ago

14.9.0-10

11 months ago

14.9.0-11

11 months ago

14.9.0-12

11 months ago

14.9.0-9

11 months ago

14.9.0-13

11 months ago

14.9.0-3

1 year ago

14.9.0-4

1 year ago

14.9.0-1

1 year ago

14.9.0-2

1 year ago

14.5.0-1

2 years ago

14.6.0-1

2 years ago

14.6.0-2

1 year ago

14.0.2-2

2 years ago

14.5.0

2 years ago

14.0.2-1

2 years ago

14.0.2

2 years ago

14.0.2-test

2 years ago