BASE

discord.js

discord.js

Backend / API library · Free

A Node.js Discord API and Gateway library: it helps create bots, commands, and server event integrations.

Also known as: discordjs/discord.js; discord-js; discordjs-library

Resource illustration: discord.js

Open resource ↗

What you can use for free

Code and local use under Apache-2.0.

Paid features and costs

Computing resources, self-hosting, and external services are paid for separately if used.

Access and limitations

Code and local use under Apache-2.0. Computing resources, self-hosting, and external services are paid for separately if used.

Use cases

  • Create a Discord bot with commands and events
  • Connect handlers to the Discord API and test a command in a test environment

Example workflow

A possible workflow; this is not a report of hands-on testing.

Create a Discord bot with commands and events.

Before you start

  • A data contract or HTTP workflow.
  • A project with a supported runtime.

Steps

  1. Define commands, Gateway events, and required bot application permissions.
  2. Connect handlers to the Discord API and test a command in a test environment.
  3. Add error handling and an integration check of the result.

Check your result

  • Invalid and missing data are handled predictably.
  • Types and the actual response agree; errors are not hidden.

Choosing discord.js

Create a Discord bot with commands and events

Choose this when

  • Create a Discord bot with commands and events
  • Connect handlers to the Discord API and test a command in a test environment

Requirements

  • The current main package README requires Node.js 24.17.0 or later; check the chosen release's requirement.

Things to consider

  • Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
  • Terms of use: Apache-2.0 for the code; third-party components retain their own terms.

Frequently asked questions

What can you use for free in discord.js?

Code and local use under Apache-2.0.

What additional costs might arise with discord.js?

Computing resources, self-hosting, and external services are paid for separately if used.

What terms of use matter for discord.js?

Apache-2.0 for the code; third-party components retain their own terms.

How do you get started with discord.js?

Define commands, Gateway events, and required bot application permissions. Connect handlers to the Discord API and test a command in a test environment. Add error handling and an integration check of the result.

What is needed for a simple slash-command bot?

The README separately demonstrates REST/Routes command registration and a Client InteractionCreate handler with Gateway intents. The voice API uses additional @discordjs/voice; zlib-sync and bufferutil are optional optimizations.

License

Apache-2.0 for the code; third-party components retain their own terms.

Apache 2.0 — permissive license with patent terms

You can use and modify the code in commercial and closed-source projects. When distributing it, retain the license and relevant notices, identify modified files, and include NOTICE if provided. Authors grant a limited patent license for their contributions; it does not grant permission to use trademarks.

License terms

Technologies and topics

  • discord.js
  • API
  • Development

Sources

Other resources