discord.js-selfbot-v13 icon indicating copy to clipboard operation
discord.js-selfbot-v13 copied to clipboard

Missing Permissions

Open k4rm1 opened this issue 1 year ago • 5 comments

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

  • [X] I have searched the open issues for duplicates.
  • [X] I have shared the entire traceback.
  • [X] I am using a user token (and it isn't visible in the code).

Additional Information

No response

k4rm1 avatar May 07 '24 15:05 k4rm1

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?

TheDevYellowy avatar May 13 '24 12:05 TheDevYellowy

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

ghost avatar May 14 '24 04:05 ghost

aiko can u reply?

zrSadek avatar Jun 23 '24 17:06 zrSadek

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));
  }
}

Combo-Miner avatar Jun 23 '24 19:06 Combo-Miner

izi

zrSadek avatar Jun 23 '24 20:06 zrSadek

You mustnt do that bc it will affect other code

aiko-chan-ai avatar Jul 02 '24 12:07 aiko-chan-ai

so can u pls find an alternative?

zrSadek avatar Jul 02 '24 15:07 zrSadek

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

aiko-chan-ai avatar Jul 02 '24 16:07 aiko-chan-ai

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

zrSadek avatar Jul 02 '24 16:07 zrSadek