discord china
Making a Discord bot can be pretty confusing and intimidating, but don’t worry! This step-by-step guide will have your own bot running in just a few minutes using Javascript and the DiscordJS library to make it easy.
打造Discord机器人可能会令人困惑和令人生畏,但请不要担心! 本分步指南将使您自己的机器人能够在短短几分钟内使用Javascript和DiscordJS库运行,从而使其变得容易。
影片教学 (Video Tutorial)
你会做什么 (What you’ll be making)
First, you’ll connect your bot and have it notify you that it’s online, then you’ll gradually add the following functionality:
首先,您将连接您的机器人并通知它它在线,然后逐步添加以下功能:
- A message reply bot to react to user messages on a given command 消息回复机器人,可根据给定命令对用户消息做出React
- A message clearing bot that takes a given number and deletes that many messages from the server 一个清除消息的漫游器,它使用给定的数字并从服务器中删除那么多消息
- A moderation bot for automatically kicking or banning users, with role-based restrictions for who can use it 审核机器人,用于自动踢出或禁止用户,并限制了角色的使用权限
- A joke bot that uses an API call to create jokes. This template can be used to make a weather bot or anything else where the relevant data can be accessed by API 使用API调用创建笑话的笑话机器人。 此模板可用于制作气象机器人或其他任何可通过API访问相关数据的地方
- A word filter moderation bot to delete messages containing words that you don’t want on your server 词过滤器审核机器人,用于删除包含服务器上不需要的单词的邮件
为什么要制造不和谐的机器人 (Why make a Discord Bot)
Discord has a massive user base with about 100 million active users, making it easy to build and grow your community. To this end, managing your Discord server through the use of a bot can be very useful. Bots can perform tasks such as welcoming users to a server, increasing the engagement of your users, and handling basic moderation tasks to keep the chaos on your server to a minimum.
Discord拥有庞大的用户群,拥有大约1亿活跃用户,这使构建和扩展社区变得容易。 为此,通过使用机器人来管理Discord服务器非常有用。 Bot可以执行诸如欢迎用户使用服务器,增加用户参与度以及处理基本审核任务等任务,以将服务器上的混乱降至最低。
The Discord API gives access to Discord functionality to the outside world, allowing users to add features that Discord itself doesn’t yet provide. Events are passed to your bot from Discord via a Websocket API connection which provides information for your bot to use. Your bot can then respond back to Discord using the REST API to perform various tasks like creating messages, changing settings on the server, and much more.
Discord API使外界可以访问Discord功能,从而允许用户添加Discord本身尚未提供的功能。 事件通过Websocket API连接从Discord传递到您的机器人,该接口提供了供您的机器人使用的信息。 然后,您的机器人可以使用REST API响应Discord,以执行各种任务,例如创建消息,更改服务器上的设置等等。
The three primary elements of a Discord bot are 1.) the users interacting with the server, 2.) the Discord Server itself, and 3.) your Discord bot running on its own server responding to events based on your code.
Discord bot的三个主要元素是1.)与服务器交互的用户; 2。Discord Server本身; 3。)运行在自己服务器上的Discord bot响应基于代码的事件。
入门 (Getting Started)
Before getting started you’ll need two things:
开始之前,您需要做两件事:
- NodeJS development environment- For this, you can either install NodeJS on your own computer along with a text editor like VS Code or use a web-based tool like CodeSandbox or Replit if you don’t want to install anything. NodeJS is a Javascript runtime that allows us to use Javascript on our server. NodeJS开发环境-为此,您可以与文本编辑器(如VS Code)一起在自己的计算机上安装NodeJS,也可以在不想安装任何东西的情况下使用基于Web的工具(如CodeSandbox或Replit)。 NodeJS是Javascript运行时,允许我们在服务器上使用Javascript。
- A Discord account and server for your bot to connect to. 机器人连接到的Discord帐户和服务器。
After getting the above setup the first thing you’ll want to do is go to the Discord Developer Portal and create your application:
完成上述设置后,您要做的第一件事是转到Discord Developer Portal并创建您的应用程序:
Next, click on your newly created application and navi