Discord JS user botting

Viewed 5783

Logging in with a user account.

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?

Error

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

Error [TOKEN_INVALID]: An invalid token was provided.

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

3 Answers

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.

From discord.js:

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

From discord.py:

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

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.

You can use https://github.com/botkalista/discord.js.userbot

const Discord = require('discord.js');
const allowUserBotting = require('discord.js.userbot');
const client = new Discord.Client();
allowUserBotting(client);
client.login('YOUR USER TOKEN HERE');

I guess they must have patched user botting on discord.js. I switched from 13.5.0 to an older version where it worked: 11.3.2.

package.json

...
    "dependencies": {
        "discord.js": "^11.3.2",
...

Of course, if you need some feature introduced in a newer version, this solution may not work for you.

Related