discord.js README

The project's README from github.com/discordjs/discord.js. As one markdown file: README.md.


discord.js


Discord server npm version npm downloads Tests status Last commit. contributors backers Code coverage

Vercel Cloudflare Workers

About

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.

Packages

Containers

Contributing

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.

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 join our Discord server.

discord.js (discordjs/discord.js)

Searching Database…

这是什么?discord.js 是一个功能强大的 Node.js 模块,用于与 Discord API 交互——实际上就是编写 Discord 机器人的主流 JavaScript/TypeScript 库。这个仓库托管着它以及它的各种辅助包。
它是一个库,还是一堆独立的包?它是一个 monorepo:包含组装好的 discord.js 封装层,外加十几个左右 @discordjs 命名空间下的辅助包,每个包都独立版本管理和发布,所以项目可以只依赖自己需要的那部分。
我怎么用它开始写机器人?在一个 Node.js 项目里从 npm 安装 discord.js 包,然后照着官方指南做;也可以运行 create-discord-bot——一个能生成现成机器人项目的命令行工具。
运行之前需要装好什么?需要一个较新的 Node.js——仓库要求 24.17.0 或更高版本。除此之外它就是一个普通的 npm 依赖,不需要额外配置什么。
大版本之间升级会很顺利吗?大版本升级需要做迁移工作:有一份专门针对 v13 升级到 v14 的更新指南,列出了变更和移除的内容,所以跨大版本升级并不是装上就能直接用。
用它写的机器人能进语音频道吗?能——语音是一等公民功能:@discordjs/voice 是一个专门用于与 Discord 语音 API 交互的模块,而且 voice-support 也是该项目列出的主题之一。
我可以只用其中一部分,而不使用完整的高级库吗?可以——@discordjs/core 是对 API 核心组件的轻量封装,@discordjs/rest 直接与 REST API 通信,@discordjs/ws 只封装网关部分。@discordjs/builders 则帮助组装 API 请求负载。
什么情况下我要跑 HTTP 代理,而不是直接调用 API?当请求需要经过中间层转发时:@discordjs/proxy 在 @discordjs/rest 基础上封装了一个面向 Discord API 的 HTTP 代理,而且仓库还提供了现成的 discordjs/proxy 容器镜像。
它适合 TypeScript 项目吗?适合——代码库本身就是用 TypeScript 写的,所以类型定义开箱即用。
Creator
discordjs
Size
66.9 MB
Stars
26.8K
Age
11y
Commits · 90 Days