aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
701 stars 145 forks source link

Missing Permissions #1163

Closed k4rm1 closed 3 days ago

k4rm1 commented 1 month ago

Which package has the bugs?

The core library

Issue description

image When I do a message.edit() with content it tells me I don't have permissions, but when I do it myself it works.

Code sample

message.edit({content: "fzefrz"})

Package version

3.1.4

Node.js version

v20.12.2.

Operating system

windows

Priority this issue should have

Medium (should be fixed soon)

Checklist

Additional Information

No response

TheDevYellowy commented 1 month ago

I know it sounds a bit dumb but are you making sure that the message you are trying to edit is a message you sent?

k4rm1 commented 1 month ago

I know it sounds a bit dumb but are you making sure that the message you are trying to edit is a message you sent?

yes, it's a message that I'm sending and coming from me

zrSadek commented 1 week ago

aiko can u reply?

Combo-Miner commented 1 week ago

Hello, i found the error its when u make the request patch to edit a message, if u have some data in the body that may be null, discord will claim it as non nullable and try to make a request without the required permissions.I just deleted the null proprietes on the body here is the fix on the APIRequest.js

    if(this.method == "patch") {
      body = JSON.parse(body)
      for(const key in body) {

        if(body[key] == null || Array.isArray(body[key]) && body[key].length == 0) {
          delete body[key];
        }
      }
      body = JSON.stringify(body)
      //return fetch(url,{method: "patch",body: JSON.stringify(body ),headers: {"Content-type": "application/json",Authorization: headers.Authorization}}).finally(() => clearTimeout(timeout));
    }
    return fetch(url, {
      method: this.method,
      headers,
      agent,
      body,
      signal: controller.signal,
    }).finally(() => clearTimeout(timeout));
  }
}
zrSadek commented 1 week ago

izi

aiko-chan-ai commented 3 days ago

You mustnt do that bc it will affect other code

zrSadek commented 3 days ago

so can u pls find an alternative?

aiko-chan-ai commented 3 days ago

so can u pls find an alternative?

I tried it but it didn't cause any error

client.on('ready', async (client) => {
    console.log('Ready!', client.user.tag);
    const c = client.channels.cache.get('id');
    const m = await c.send('abc');
    m.edit({
        content: 'def'
    });
});

image

zrSadek commented 3 days ago

its when u have only message perm on a server and others like attachements or voice message