本文介绍了Discord JS 用户机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我注意到在 Discord 上使用带有 Python 的机器人非常容易,但在 Node JS 上却不可能?我的意思是,必须有一种方法可以使用 Node JS 登录用户帐户,有人知道吗?

Ok so, I noticed that it's extremely easy to use a bot with Python on Discord, but it's not possible on Node JS? I mean, there must be a way to log in to a user account with Node JS, anybody know?

每当尝试使用 discord.js 登录用户帐户时,它都会回复:

Whenever trying to log in to a user account with discord.js, it replies with this:

Error [TOKEN_INVALID]: An invalid token was provided.

我很好奇;我想做一些能与uwu"反应的东西.每次有人说uwu".

I'm pretty curious; I'd like to make something that would react with "uwu" every time someone says "uwu".

推荐答案

不同的库,不同的自由度.您观察到使用 discord.js 是不可能的,但使用 discord.py 是可能的.
要么使用 Python 库,要么编辑 JavaScript 库.

Different libraries, different degrees of freedom. You observed it is not possible with discord.js but it is possible with discord.py.
Either use the Python library or you edit the JavaScript library.

来自 discord.js:

headers: { Authorization: `Bot ${token.replace(/^Bots*/i, '')}` },

来自 discord.py:

headers['Authorization'] = 'Bot ' + self.token if self.bot_token else self.token

两者之间的唯一区别是 Authorization 标头.在 discord.py 中,当提供 Bot 令牌时,该令牌以 Bot 为前缀.当提供用户令牌时,没有 Bot 前缀.
在 discord.js 中,始终提供 Bot 前缀,使其仅适用于机器人令牌.

The only difference between the two of them is the Authorization header. In discord.py when a Bot token is supplied the token is prefixed with Bot . When a User token is supplied there is no Bot prefix.
In discord.js the Bot prefix is always supplied leading it to only work with bot tokens.

这是我能提供的最大帮助.如果您对这些信息无能为力,那么您只能靠自己了.

This is the most help I'll offer. If you can't do anything with this information then you are on your own.

这篇关于Discord JS 用户机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:02