Discord 凭据(Discord credentials)#
你可以使用以下凭据验证以下节点:
🌐 You can use these credentials to authenticate the following nodes:
先决条件(Prerequisites)#
- 创建一个 Discord 账户。
- 对于 Bot 和 OAuth2 凭证:
- 有关 webhook 凭据,请创建一个 webhook。
支持的身份验证方法(Supported authentication methods)#
- 机器人
- OAuth2
- Webhook
不确定使用哪种方法?请参考选择身份验证方法以获取更多指导。
🌐 Not sure which method to use? Refer to Choose an authentication method for more guidance.
相关资源(Related resources)#
有关该服务的更多信息,请参考Discord开发者文档。
🌐 Refer to Discord's Developer documentation for more information about the service.
使用机器人(Using bot)#
如果你想使用机器人令牌而不是 OAuth2 将机器人添加到你的 Discord 服务器,请使用此方法。
🌐 Use this method if you want to add the bot to your Discord server using a bot token rather than OAuth2.
要配置此凭据,你需要:
🌐 To configure this credential, you'll need:
- Bot 令牌:在你创建带有机器人的应用后生成。
要创建一个带有机器人的应用并生成 机器人令牌:
🌐 To create an application with a bot and generate the Bot Token:
- 如果你还没有,请在开发者门户中创建一个应用。
- 为你的应用输入一个名称。
- 选择 创建。
- 从左侧菜单中选择 Bot。
- 在 Token 下,选择 重置 Token 以生成新的机器人令牌。
- 复制令牌并将其添加到你的 n8n 凭证中。
- 在 Bot > 特权网关意图 中,添加你希望你的机器人拥有的任何特权意图。有关特权意图的更多信息,请参阅 配置你的机器人。
- n8n 建议启用 服务器成员意图:您的机器人需要此权限才能接收列在 GUILD_MEMBERS 下的事件。
- 在 安装 > 安装上下文 中,选择你希望机器人使用的安装上下文:
- 选择 公会安装 以安装服务器应用。(n8n 用户最常用的方式。)
- 选择用户安装以安装用户应用。(对于 n8n 用户来说不常见,但可能对测试有用。)
- 有关这些安装环境的更多信息,请参阅 Discord 的 选择安装环境 文档。
- 在 安装 > 安装链接 中,如果尚未选择,请选择 Discord 提供的链接。10. 仍在 安装 页面,在 默认安装设置 部分,选择
applications.commands和bot范围。有关这些及其他范围的更多信息,请参阅 Discord 的 Scopes 文档。11. 在 Bot > Bot 权限 页面添加权限。有关更多信息,请参阅 Discord 的 Permissions 文档。n8n 建议为 Discord 节点选择这些权限:- 管理角色
- 管理通道
- 读取消息/查看通道
- 发送消息
- 创建公共线程
- 创建私有线程
- 以线程形式发送消息
- 发送文本转语音消息
- 管理消息
- 管理主题
- 嵌入链接
- 附加文件
- 读取消息历史记录
- 添加反应12。将应用添加到你的服务器或测试服务器: 1. 转到 安装 > 安装链接 并复制那里列出的链接。 2. 将链接粘贴到浏览器中并按 Enter 键。 1. 在安装提示中选择 添加到服务器。 1. 应用添加到服务器后,你将在成员列表中看到它。
这些步骤概述了设置 n8n 凭证所需的基本功能。有关创建应用的更多信息,请参考 Discord 创建应用 指南,特别是:
🌐 These steps outline the basic functionality needed to set up your n8n credential. Refer to the Discord Creating an App guide for more information on creating an app, especially:
使用 OAuth2(Using OAuth2)#
如果你想使用 OAuth2 流程将机器人添加到 Discord 服务器,请使用此方法,这可以简化用户安装你的应用的过程。
🌐 Use this method if you want to add the bot to Discord servers using the OAuth2 flow, which simplifies the process for those installing your app.
要配置此凭据,你需要:
🌐 To configure this credential, you'll need:
- 客户端 ID
- 客户端密钥
- 选择是在 Header 还是 Body 中发送 Authentication
- 一个 机器人令牌
有关创建带有机器人的应用并生成令牌的详细信息,请按照上面 使用机器人 中的相同步骤操作。
🌐 For details on creating an application with a bot and generating the token, follow the same steps as in Using bot above.
然后:
🌐 Then:
- 复制你生成的 Bot Token 并将其添加到 n8n 凭证中。
- 在你的 Discord 应用中打开 OAuth2 页面以访问你的 客户端 ID 并生成 客户端密钥。将这些信息添加到你的 n8n 凭证中。
- 在 n8n 中,复制 OAuth 重定向 URL 并将其添加到 Discord 应用的 OAuth2 > Redirects 中。确保保存这些更改。
使用 Webhook(Using webhook)#
要配置此凭据,你需要:
🌐 To configure this credential, you'll need:
- 一个 Webhook URL:在你创建 webhook 后生成。
要获取 Webhook URL,请创建一个 Webhook 并复制生成的 URL:
🌐 To get a Webhook URL, you create a webhook and copy the URL that gets generated:
- 打开你的 Discord 服务器设置,然后进入 集成 标签。
- 选择 创建 Webhook 以创建新的 Webhook。
- 为你的 webhook 取一个有意义的名称。
- 点击 名称 旁边的 头像 来编辑或上传新头像。
- 在 CHANNEL 下拉菜单中,选择 webhook 应发布到的通道。
- 选择 复制 Webhook URL 来复制 Webhook URL。在你的 n8n 凭证中输入此 URL。
有关更多信息,请参阅Discord 创建 Webhook 文档。
🌐 Refer to the Discord Making a Webhook documentation for more information.
选择身份验证方法(Choose an authentication method)#
最简单的安装方式是Webhooks(网络钩子)。你可以在 Discord 服务器的单个通道上创建并添加 Webhooks。Webhooks 可以向通道发送消息。它们不需要机器人用户或身份验证。但它们无法监听或响应用户请求或命令。如果你需要一种简单的方法向通道发送消息,而不需要交互或反馈,请使用 Webhook。
🌐 The simplest installation is a webhook. You create and add webhooks to a single channel on a Discord server. Webhooks can post messages to a channel. They don't require a bot user or authentication. But they can't listen or respond to user requests or commands. If you need a straightforward way to send messages to a channel without the need for interaction or feedback, use a webhook.
机器人(bot) 是比 webhook 更具交互性的升级。你可以将机器人添加到 Discord 服务器(在 Discord API 文档中称为 guild)或用户账户。添加到服务器的机器人可以在服务器的所有通道与用户互动。它们可以管理通道、发送和获取消息、获取所有用户列表,并更改用户的角色。如果你需要构建互动性强、复杂或多步骤的工作流程,请使用机器人。
🌐 A bot is an interactive step up from a webhook. You add bots to the Discord server (referred to as a guild in the Discord API documentation) or to user accounts. Bots added to the server can interact with users on all the server's channels. They can manage channels, send and retrieve messages, retrieve the list of all users, and change their roles. If you need to build an interactive, complex, or multi-step workflow, use a bot.
OAuth2 基本上是一个使用 OAuth2 流程的 机器人,而不仅仅是使用机器人令牌。和机器人一样,你可以将它们添加到 Discord 服务器或用户账户中。这些凭证提供与机器人相同的功能,但它们可以简化在你的服务器上安装机器人的过程。