botkalista / discord.js.userbot

Allow discord.js to login as User
MIT License
25 stars 6 forks source link

Can't send messages to channels? #10

Open VioletFlare opened 2 years ago

VioletFlare commented 2 years ago

I can fetch the guilds and the channels but I can't send messages to the channels. Currently using discord.js 12.5.3.

Basically, what I am doing with the code (i am using the latest 1.0.3 version from npm) is providing the token from my browser session. Thus instantiating the client login.

And then getting the channel I want, like so:

client.on("ready", async () => {
    const guild = client.guilds.cache.find(
        guild => guild.name === guildname 
    )

    channel = guild.channels.cache.find(
        channel => channel.name === channelname
    );
})

Then at some point i'd like to use:

channel.send(messageString);

At this point i get the following error:

DiscordAPIError: 401: Unauthorized
    at RequestHandler.execute (C:\Users\x\Desktop\code\selfbot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\x\Desktop\code\selfbot\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
  method: 'post',
  path: '/channels/<channelnumber>/messages',
  code: 0,
  httpStatus: 401
}

Is this discord finally disallowing selfbots or it can be fixed?

P.S. <channelnumber> - I have omitted the channel number from the code quote manually.

Alliegaytor commented 2 years ago

The exact same issue is present on discord.js 12.3.1