discord china_如何使用Node.js构建Discord Bot

discord china

介绍 (Introduction)

Discord is a chat application that allows millions of users across the globe to message and voice chat online in communities called guilds or servers. Discord also provides an extensive API that developers can use to build powerful Discord bots. Bots can perform various actions such as sending messages to servers, DM-ing users, moderating servers, and playing audio in voice chats. This allows developers to craft powerful bots that include advanced, complex features like moderation tools or even games. For example, the utility bot Dyno serves millions of guilds and contains useful features such as spam protection, a music player, and other utility functions. Learning how to create Discord bots allows you to implement many possibilities, which thousands of people could interact with every day.

Discord是一个聊天应用程序,它使全球数百万的用户可以在称为公会或服务器的社区中在线进行消息和语音聊天。 Discord还提供了广泛的API,开发人员可以使用它们来构建功能强大的Discord机器人。 漫游器可以执行各种操作,例如将消息发送到服务器,DM-ing用户,对服务器进行审核以及在语音聊天中播放音频。 这使开发人员可以制作功能强大的机器人,其中包括高级,复杂的功能,例如审核工具或游戏。 例如,实用程序Dyno服务于数百万个行会,并包含有用的功能,例如垃圾邮件防护,音乐播放器和其他实用程序功能。 学习如何创建Discord机器人可以使您实现许多可能性,每天都有成千上万的人可以与之互动。

In this tutorial, you will build a Discord bot from scratch, using Node.js and the Discord.js library, which allows users to directly interact with the Discord API. You’ll set up a profile for a Discord bot, get authentication tokens for the bot, and program the bot with the ability to process commands, with arguments, from users.

在本教程中,您将使用Node.jsDiscord.js库从头开始构建Discord机器人,该库允许用户直接与Discord API进行交互。 您将为Discord机器人设置一个配置文件,获取该机器人的身份验证令牌,并对该机器人进行编程,使其能够处理来自用户的带有参数的命令。

先决条件 (Prerequisites)

Before you get started, you will need the following:

在开始之前,您需要满足以下条件:

第1步-设置Discord Bot (Step 1 — Setting Up a Discord Bot)

In this step, you’ll use the Discord developers GUI to set up a Discord bot and get the bot’s token, which you will pass into your program.

在此步骤中,您将使用Discord开发人员GUI设置Discord机器人并获取该机器人的令牌,并将其传递到您的程序中。

In order to register a bot on the Discord platform, use the Discord application dashboard. Here developers can create Discord applications including Discord bots.

为了在Discord平台上注册机器人,请使用Discord应用程序仪表板 。 在这里,开发人员可以创建包括Discord机器人在内的Discord应用程序。

To get started, click New Application. Discord will ask you to enter a name for your new application. Then click Create to create the application.

首先,点击新建应用程序 。 Discord会要求您输入新应用程序的名称。 然后单击创建以创建应用程序。

Note: The name for your application is independent from the name of the bot, and the bot doesn’t have to have the same name as the application.

注意:您的应用程序的名称与机器人的名称无关,并且机器人不必与应用程序具有相同的名称。

Now open up your application dashboard. To add a bot to the application, navigate to the Bot tab on the navigation bar to the left.

现在打开您的应用程序仪表板。 要将机器人添加到应用程序,请导航至左侧导航栏上的Bot标签。

Click the Add Bot button to add a bot to the application. Click the Yes, do it! button when it prompts you for confirmation. You will then be on a dashboard containing details of your bot’s name, authentication token, and profile picture.

单击“ 添加漫游器”按钮以将漫游器添加到应用程序。 单击是,执行! 提示您进行确认时,请单击。 然后,您将在仪表板上,其中包含机器人名称,身份验证令牌和个人资料图片的详细信息。

You can modify your bot’s name or profile picture here on the dashboard. You also need to copy the bot’s authentication token by clicking Click to Reveal Token and copying the token that appears.

您可以在信息中心上的此处修改机器人的名称或个人资料图片。 您还需要通过单击“ 单击以显示令牌”并复制显示的令牌来复制漫游器的身份验证令牌。

Warning: Never share or upload your bot token as it allows anyone to log in to your bot.

警告:切勿共享或上传您的机器人令牌,因为它允许任何人登录到您的机器人。

Now you need to create an invite that allows you to add the bot Discord guilds where you can test the bot. First, navigate to the OAuth2 tab of the application dashboard. To create an invite, scroll down and select bot under scopes. You must also set permissions to control what actions your bot can perform in guilds. For the purposes of this tutorial, select Administrator, which will give your bot permission to perform nearly all actions in guilds. Copy the link with the Copy button.

现在,您需要创建一个邀请,以允许您在其中添加可以测试机器人的机器人Discord公会。 首先,导航到应用程序仪表板的OAuth2标签。 要创建邀请,请向下滚动并在scopes下选择bot 。 您还必须设置权限以控制您的机器人可以在行会中执行的操作。 在本教程中,选择Administrator ,这将使您的机器人具有执行公会中几乎所有动作的权限。 使用“ 复制”按钮复制链接。

Next, add the bot to a server. Follow the invite link you just created. You can add the bot to any server you own, or have administrator permissions in, from the drop-down menu.

接下来,将漫游器添加到服务器。 跟随您刚刚创建的邀请链接。 您可以从下拉菜单中将漫游器添加到您拥有的任何服务器中,或拥有管理员权限。

Now click Continue. Ensure you have the tickbox next to Administrator ticked—this will grant the bot administrator permissions. Then click Authorize. Discord will ask you to solve a CAPTCHA before the bot joins the server. You’ll now have the Discord bot on the members list in the server you added the bot to under offline.

现在,单击继续 。 确保选中管理员旁边的复选框,这将授予漫游器管理员权限。 然后单击授权 。 在僵尸程序加入服务器之前,Discord会要求您解决验证码 。 现在,您将Discord bot添加到离线添加到服务器的成员列表中。

You’ve successfully created a Discord bot and added it to a server. Next, you will write a program to log in to the bot.

您已经成功创建了Discord机器人并将其添加到服务器。 接下来,您将编写一个程序以登录到bot。

第2步-创建项目 (Step 2 — Creating Your Project)

In this step, you’ll set up the basic coding environment where you will build your bot and log in to the bot programmatically.

在此步骤中,您将设置基本的编码环境,在该环境中您将构建机器人并以编程方式登录到该机器人。

First, you need to set up a project folder and necessary project files for the bot.

首先,您需要为机器人设置一个项目文件夹和必要的项目文件。

Create your project folder:

创建您的项目文件夹:

  • mkdir discord-bot

    mkdir Discord-bot

Move into the project folder you just created:

移至您刚刚创建的项目文件夹:

  • cd discord-bot

    cd Discord-bot

Next, use your text editor to create a file named config.json to store your bot’s authentication token:

接下来,使用文本编辑器创建一个名为config.json的文件来存储您的机器人的身份验证令牌:

  • nano config.json

    纳米config.json

Then add the following code to the config file, replacing the highlighted text with your bot’s authentication token:

然后将以下代码添加到配置文件中,将突出显示的文本替换为您的机器人的身份验证令牌:

config.json
config.json
{
    "BOT_TOKEN": "YOUR BOT TOKEN"
}

Save and exit the file.

保存并退出文件。

Next you’ll create a package.json file, which will store details of your project and information about the dependencies you’ll use for the project. You’ll create a package.json file by running the following npm command:

接下来,您将创建一个package.json文件,该文件将存储项目的详细信息以及有关将用于该项目的依赖项的信息。 您将通过运行以下npm命令来创建package.json文件:

  • npm init

    npm初始化

npm will ask you for various details about your project. If you would like guidance on completing these prompts, you can read about them in How To Use Node.js Modules with npm and package.json.

npm将询问您有关项目的各种详细信息。 如果您想获得有关完成这些提示的指导,可以在如何通过npm和package.json使用Node.js模块中阅读有关它们的信息

You’ll now install the discord.js package that you will use to interact with the Discord API. You can install discord.js through npm with the following command:

现在,您将安装用于与Discord API交互的discord.js软件包。 您可以使用以下命令通过npm安装discord.js

  • npm install discord.js

    npm安装discord.js

Now you’ve set up the configuration file and installed the necessary dependency, you’re ready to begin building your bot. In a real-world application, a large bot would be split across many files, but for the purposes of this tutorial, the code for your bot will be in one file.

现在,您已经设置了配置文件并安装了必要的依赖项,您就可以开始构建机器人了。 在实际的应用程序中,大型机器人将被分割成许多文件,但出于本教程的目的,您的机器人代码将在一个文件中。

First, create a file named index.js in the discord-bot folder for the code:

首先,在discord-bot文件夹中为该代码创建一个名为index.js的文件:

  • nano index.js

    纳米index.js

Begin coding the bot by requiring the discord.js dependency and the config file with the bot’s token:

通过要求discord.js依赖项和带有机器人令牌的配置文件开始对机器人进行编码:

index.js
index.js
const Discord = require("discord.js");
const config = require("./config.json");

Following this, add the next two lines of code:

之后,添加以下两行代码:

index.js
index.js
...
const client = new Discord.Client();

client.login(config.BOT_TOKEN);

Save and exit your file.

保存并退出文件。

The first line of code creates a new Discord.Client and assigns it to the constant client. This client is partly how you will interact with the Discord API and how Discord will notify you of events such as new messages. The client, in effect, represents the Discord bot.

代码的第一行创建一个新的Discord.Client并将其分配给常量client 。 此客户端部分是您如何与Discord API交互以及Discord如何将诸如新消息之类的事件通知您。 实际上,客户端代表Discord机器人。

The second line of code uses the login method on the client to log in to the Discord bot you created, using the token in the config.json file as a password. The token lets the Discord API know which bot the program is for and that you’re authenticated to use the bot.

第二行代码使用config.json文件中的令牌作为密码,使用client上的login方法登录到您创建的Discord bot。 该令牌可让Discord API知道程序用于哪个机器人以及您已通过身份验证以使用该机器人。

Now, execute the index.js file using Node:

现在,使用Node执行index.js文件:

  • node index.js

    节点index.js

Your bot’s status will change to online in the Discord server you added it to.

您添加的Discord服务器中,机器人的状态将变为在线。

You’ve successfully set up a coding environment and created the basic code for logging in to a Discord bot. In the next step you’ll handle user commands and get your bot to perform actions, such as sending messages.

您已经成功设置了编码环境,并创建了用于登录Discord机器人的基本代码。 在下一步中,您将处理用户命令并让您的机器人执行操作,例如发送消息。

步骤3 —处理您的第一个用户命令 (Step 3 — Handling Your First User Command)

In this step, you will create a bot that can handle user commands. You will implement your first command ping, which will respond with "pong" and the time taken to respond to the command.

在此步骤中,您将创建一个可以处理用户命令的机器人。 您将实现第一个命令ping ,该命令将以"pong"以及响应该命令所花费的时间进行响应。

First, you need to detect and receive any messages users send so you can process any commands. Using the on method on the Discord client, Discord will send you a notification about new events. The on method takes two arguments: the name of an event to wait for and a function to run every time that event occurs. With this method you can wait for the event message—this will occur every time a message is sent to a guild where the bot has permission to view messages. Therefore let’s create a function, which runs every time a message is sent, to process commands.

首先,您需要检测并接收用户发送的任何消息,以便您可以处理任何命令。 使用Discord客户端上的on方法,Discord将向您发送有关新事件的通知。 on方法采用两个参数:要等待的事件的名称和每次该事件发生时要运行的函数。 使用这种方法,您可以等待事件message -每当将消息发送到机器人有权查看消息的行会时,就会发生此事件。 因此,让我们创建一个函数,该函数在每次发送消息时都会运行,以处理命令。

First open your file:

首先打开文件:

  • nano index.js

    纳米index.js

Add the following code to your file:

将以下代码添加到您的文件中:

index.js
index.js
...
const client = new Discord.Client();


client.on("message", function(message) { 
                                         
});                                      

client.login(config.BOT_TOKEN);

This function, which runs on the message event, takes message as a parameter. message will have the value of a Discord.js message instance, which contains information about the sent message and methods to help the bot respond.

message事件上运行的此函数将message作为参数。 message将具有Discord.js消息实例的值,该实例包含有关已发送消息的信息以及帮助该bot响应的方法。

Now add the following line of code to your command-handling function:

现在,将以下代码行添加到您的命令处理函数中:

index.js
index.js
...
client.on("message", function(message) {
  if (message.author.bot) return;
});
...

This line checks if the author of the message is a bot, and if so, stops processing the command. This is important as generally you don’t want to process, or respond to, bots’ messages. Bots usually don’t need to, or want to, be using our bot, so ignoring their messages saves processing power and helps prevent accidental replies.

此行检查消息的作者是否是机器人,如果是,则停止处理该命令。 这很重要,因为通常您不想处理或响应机器人的消息。 机器人通常不需要或不想使用我们的机器人,因此忽略它们的消息可以节省处理能力,并有助于防止意外回复。

Now you’ll write a command handler. To accomplish this, it’s good to understand the usual format of a Discord command. Typically, the structure of a Discord command contains three parts in the following order: a prefix, a command name, and (sometimes) command arguments.

现在,您将编写命令处理程序。 为此,最好理解Discord命令的常用格式。 通常,Discord命令的结构按以下顺序包含三部分:前缀,命令名称和(有时)命令参数。

  • Prefix: the prefix can be anything, but is typically a piece of punctuation or abstract phrase that wouldn’t normally be at the start of a message. This means that when you include the prefix at the start of the message, the bot will know that the intention for this command is for a bot to process it.

    前缀:前缀可以是任何东西,但通常是标点符号或抽象短语,通常不在消息开头。 这意味着,当您在消息的开头包含前缀时,机器人将知道此命令的意图是机器人对其进行处理。

  • Command name: The name of the command the user wants to use. This means the bot can support multiple commands with different functionality and allow users to choose between them by supplying a different command name.

    命令名称:用户要使用的命令的名称。 这意味着该机器人可以支持具有不同功能的多个命令,并允许用户通过提供不同的命令名称在它们之间进行选择。

  • Arguments: Sometimes if the command requires or uses extra information from the user, the user can supply arguments after the command name, with each argument separated by a space.

    参数:有时,如果命令需要或使用来自用户的其他信息,则用户可以在命令名称后提供参数,每个参数之间用空格分隔。

Note: There is no enforced command structure and bots can process commands how they like, but the structure presented here is an efficient structure that the vast majority of bots use.

注意:没有强制的命令结构,机器人可以按自己喜欢的方式处理命令,但是这里介绍的结构是大多数机器人使用的高效结构。

To begin creating a command parser that handles this format, add the following lines of code to the message handling function:

要开始创建处理这种格式的命令解析器,请将以下代码行添加到消息处理功能中:

index.js
index.js
...
const prefix = "!";

client.on("message", function(message) {
  if (message.author.bot) return;
  if (!message.content.startsWith(prefix)) return;
});
...

You add the first line of code to assign the value "!" to the constant prefix, which you will use as the bot’s prefix.

您添加第一行代码以分配值"!" 到常量prefix ,您将用作机器人的前缀。

The second line of code you add checks if the content of the message the bot is processing begins with the prefix you set, and if it doesn’t, stops the message from continuing to process.

您添加的第二行代码检查机器人正在处理的消息的内容是否以您设置的前缀开头,如果不是,则停止继续处理消息。

Now you must convert the rest of the message into a command name and any arguments that may exist in the message. Add the following highlighted lines:

现在,您必须将消息的其余部分转换为命令名称以及消息中可能存在的所有参数。 添加以下突出显示的行:

index.js
index.js
...
client.on("message", function(message) {
  if (message.author.bot) return;
  if (!message.content.startsWith(prefix)) return;

  const commandBody = message.content.slice(prefix.length);
  const args = commandBody.split(' ');
  const command = args.shift().toLowerCase();
});
...

You use the first line here to remove the prefix from the message content and assign the result to the constant commandBody. This is necessary as you don’t want to include the prefix in the parsed command name.

您在此处使用第一行从消息内容中删除前缀,并将结果分配给常量commandBody 。 这是必需的,因为您不想在已解析的命令名称中包括前缀。

The second line takes the message with the removed prefix and uses the split method on it, with a space as the separator. This splits it into an array of sub-strings, making a split wherever there is a space. This results in an array containing the command name then, if included in the message, any arguments. You assign this array to the constant args.

第二行接收带有已删除前缀的消息,并在其上使用split方法 ,并以空格作为分隔符。 这会将其拆分为子字符串数组,并在有空格的地方进行拆分。 这将导致一个包含命令名称的数组,如果消息中包含该命令名称,则包含任何参数。 您将此数组分配给常量args

The third line removes the first element from the args array (which will be the command name provided), converts it to lowercase, and then assigns it to the constant command. This allows you to isolate the command name and leave only arguments in the array. You also use the method toLowerCase as commands are typically case insensitive in Discord bots.

第三行从args数组中删除第一个元素(将提供命令名称),将其转换为小写字母,然后将其分配给constant command 。 这使您可以隔离命令名称,并仅在数组中保留参数。 您还可以使用toLowerCase方法,因为在Discord机器人中,命令通常不区分大小写。

You’ve completed building a command parser, implementing a required prefix, and getting the command name and any arguments from messages. You will now implement and create the code for the specific commands.

您已经完成了命令解析器的构建,实现了必需的前缀,并从消息中获取了命令名称和所有参数。 现在,您将实现并创建特定命令的代码。

Add the following code to start implementing the ping command:

添加以下代码以开始实施ping命令:

index.js
index.js
...
  const args = commandBody.split(' ');
  const command = args.shift().toLowerCase();

  if (command === "ping") {
                           
  }                        
});
...

This if statement checks if the command name you parsed (assigned to the constant command) matches "ping". If it does, that indicates the user wants to use the "ping" command. You will nest the code for the specific command inside the if statement block. You will repeat this pattern for other commands you want to implement.

if语句检查您解析的命令名称(分配给常量command )是否与"ping"相匹配。 如果是这样,则表明用户要使用"ping"命令。 您将在if语句块中嵌套特定命令的代码。 您将对要实现的其他命令重复此模式。

Now, you can implement the code for the "ping" command:

现在,您可以实现"ping"命令的代码:

index.js
index.js
...
  if (command === "ping") {
    const timeTaken = Date.now() - message.createdTimestamp;
    message.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
  }
...

Save and exit your file.

保存并退出文件。

You add the "ping" command block that calculates the difference between the current time—found using the now method on the Date object—and the timestamp when the message was created in milliseconds. This calculates how long the message took to process and the "ping" of the bot.

您添加了"ping"命令块,该命令块计算当前时间(以Date对象的now方法找到)与创建消息的时间戳之间的时差(以毫秒为单位)。 这将计算处理消息所花费的时间以及机器人的"ping"

The second line responds to user’s command using the reply method on the message constant. The reply method pings (which notifies the user and highlights the message for the specified user) the user who invoked the command, followed by the content provided as the first argument to the method. You provide a template literal containing a message and the calculated ping as the response that the reply method will use.

第二行使用message常量上的reply方法响应用户的命令。 reply方法对调用该命令的用户执行ping操作(通知用户并突出显示指定用户的消息),随后是作为该方法的第一个参数提供的内容。 您提供一个模板文字,其中包含一条消息和计算出的ping作为reply方法将使用的响应。

This concludes implementing the "ping" command.

至此,实现了"ping"命令。

Run your bot using the following command (in the same folder as index.js):

使用以下命令(与index.js相同的文件夹中)运行您的机器人:

  • node index.js

    节点index.js

You can now use the command "!ping" in any channel the bot can view and message in, resulting in a response.

现在,您可以在漫游器可以查看并向其发送消息的任何通道中使用命令"!ping" ,以产生响应。

You have successfully created a bot that can handle user commands and you have implemented your first command. In the next step, you will continue developing your bot by implementing a sum command.

您已经成功创建了一个可以处理用户命令的机器人,并且已经实现了第一个命令。 在下一步中,您将通过实现sum命令来继续开发您的机器人。

步骤4 —实施Sum命令 (Step 4 — Implementing the Sum Command)

Now you will extend your program by implementing the "!sum" command. The command will take any number of arguments and add them together, before returning the sum of all the arguments to the user.

现在,您将通过实现"!sum"命令来扩展程序。 在将所有参数的总和返回给用户之前,该命令将使用任意数量的参数并将其添加在一起。

If your Discord bot is still running, you can stop its process with CTRL + C.

如果Discord bot仍在运行,则可以使用CTRL + C停止其进程。

Open your index.js file again:

再次打开index.js文件:

  • nano index.js

    纳米index.js

To begin implementing the "!sum" command you will use an else-if block. After checking for the ping command name, it will check if the command name is equal to "sum". We use an else-if block since only one command will process at a time, so if the program matches the command name "ping", it doesn’t have to check for the "sum" command. Add the following highlighted lines to your file:

要开始执行"!sum"命令,您将使用else-if块。 检查ping命令名称后,它将检查命令名称是否等于"sum" 。 我们使用else-if块,因为一次只处理一个命令,因此,如果程序与命令名"ping"相匹配,则不必检查"sum"命令。 将以下突出显示的行添加到您的文件中:

index.js
index.js
...
  if (command === "ping") {
    const timeTaken = Date.now() - message.createdTimestamp;
    message.reply(`Ping! This message had a latency of ${timeTaken}ms.`);
  }

  else if (command === "sum") {
                               
  }                            
});
...

You can begin implementing the code for the "sum" command. The code for the "sum" command will go inside the else-if block you just created. Now, add the following code:

您可以开始实现"sum"命令的代码。 "sum"命令的代码将在您刚创建的else-if块内。 现在,添加以下代码:

index.js
index.js
...
  else if (command === "sum") {
    const numArgs = args.map(x => parseFloat(x));
    const sum = numArgs.reduce((counter, x) => counter += x);
    message.reply(`The sum of all the arguments you provided is ${sum}!`);
  }
...

You use the map method on the arguments list to create a new list by using the parseFloat function on each item in the args array. This creates a new array (assigned to the constant numArgs) in which all of the items are numbers instead of strings. This means later you can successfully find the sum of the numbers by adding them together.

通过对args数组中的每个项目使用parseFloat函数,可以在参数列表上使用map方法来创建新列表。 这将创建一个新数组(分配给常量numArgs ),其中所有项目均为数字而不是字符串。 这意味着以后您可以通过将它们加在一起来成功找到这些数字的总和。

The second line uses the reduce method on the constant numArgs providing a function that totals all the elements in the list. You assign the sum of all the elements in numArgs to the constant sum.

第二行在常量numArgs上使用reduce方法 ,该函数提供一个将列表中所有元素numArgs的函数。 您将numArgs中所有元素的和分配给常数sum

You then use the reply method on the message object to reply to the user’s command with a template literal, which contains the sum of all the arguments the user sends to the bot.

然后,您可以在消息对象上使用reply方法,以模板常量答复用户的命令,该模板常量包含用户发送给bot的所有参数的总和。

This concludes implementing the "sum" command. Now run the bot using the following command (in the same folder as index.js):

至此,实现了"sum"命令。 现在,使用以下命令(与index.js相同的文件夹中)运行该机器人:

  • node index.js

    节点index.js

You can now use the "!sum" command in any channel the bot can view and message in.

现在,您可以在漫游器可以查看和向其发送消息的任何通道中使用"!sum"命令。

The following is a completed version of the index.js bot script:

以下是index.js机器人脚本的完整版本:

index.js
index.js
const Discord = require("discord.js");
const config = require("./config.json");

const client = new Discord.Client();

const prefix = "!";

client.on("message", function(message) {
  if (message.author.bot) return;
  if (!message.content.startsWith(prefix)) return;

  const commandBody = message.content.slice(prefix.length);
  const args = commandBody.split(' ');
  const command = args.shift().toLowerCase();

  if (command === "ping") {
    const timeTaken = Date.now() - message.createdTimestamp;
    message.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
  }

  else if (command === "sum") {
    const numArgs = args.map(x => parseFloat(x));
    const sum = numArgs.reduce((counter, x) => counter += x);
    message.reply(`The sum of all the arguments you provided is ${sum}!`);
  }
});

client.login(config.BOT_TOKEN);

In this step, you have further developed your Discord bot by implementing the sum command.

在此步骤中,您通过实现sum命令进一步开发了Discord机器人。

结论 (Conclusion)

You have successfully implemented a Discord bot that can handle multiple, different user commands and command arguments. If you want to expand on your bot, you could possibly implement more commands or try out more parts of the Discord API to craft a powerful Discord bot. You can review the Discord.js documentation or the Discord API documentation to expand your knowledge of the Discord API.

您已经成功实现了Discord机器人,该机器人可以处理多个不同的用户命令和命令参数。 如果要扩展您的机器人,则可以实现更多命令或尝试使用Discord API的更多部分来构建功能强大的Discord机器人。 您可以查看Discord.js文档Discord API文档,以扩展您对Discord API的了解。

While creating Discord bots, you must always keep in mind the Discord API terms of service, which outlines how developers must use the Discord API. You could also read this set of guidelines on how to best implement a Discord bot and provides tips on how to design Discord bots. If you would like learn more about Node.js check out our How To Code in Node.js series.

创建Discord机器人时,必须始终牢记Discord API服务条款 ,该条款概述了开发人员必须如何使用Discord API。 您还可以阅读关于如何最佳实现Discord机器人的这套指南 ,并提供有关如何设计Discord机器人的提示。 如果您想了解有关Node.js的更多信息,请查看我们的Node.js系列代码

翻译自: https://www.digitalocean.com/community/tutorials/how-to-build-a-discord-bot-with-node-js

discord china

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值