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
751 stars 160 forks source link

Unable to send regular message without file permissions #1259

Closed 1xChloe closed 1 week ago

1xChloe commented 3 weeks ago

Which package has the bugs?

The core library

Issue description

How I structure my message payload (yes I've debugged to make sure its just a single string) then running a simple msg.reply in a server channel without file perms, even if the return is just a string will cause it to error saying Missing Permissions

Code sample

const getResponseContent = (resp) => {
  if (resp.choices[0].message.content === undefined) {
    return "There was an issue processing, try a simpler question";
  }
  return resp.choices[0].message.content;
};

const handleResponse = (resp, msg) => {
  const isLong =
    msg.client.user.premiumType === 2 ? resp.length > 4000 : resp.length > 2000;

  let finalResponse = getResponseContent(resp);

  if (isLong) {
    finalResponse = {
      text: finalResponse,
    };
  }

  return finalResponse;
};

Package version

3.3.0

Node.js version

19

Operating system

Linux Debian

Priority this issue should have

Medium (should be fixed soon)

Checklist

Additional Information

No response

aiko-chan-ai commented 3 weeks ago

Could you describe it more clearly?

1xChloe commented 2 weeks ago

Could you describe it more clearly?

When trying to get the selfbot to send a regular message in a guild, if the account doesn't have the permission to send files/attachments it will error saying missing permissions, even if there is no file attached.

aiko-chan-ai commented 2 weeks ago

When trying to get the selfbot to send a regular message in a guild, if the account doesn't have the permission to send files/attachments it will error saying missing permissions, even if there is no file attached.

Could you write a small piece of code and share the error message with me?

1xChloe commented 2 weeks ago

My bad, updated code and the error (You can run this with eval and it'll crash)

let tempSend = msg.channel.send("Test Message")

function sendResponse(msg, response, sentMsg) {
  let hasFile = false;
  if (
    msg.client.user.premiumType === 2
      ? response.length > 4000
      : response.length > 2000
  )
    hasFile = true;

  if (hasFile) {
    await sentMsg.edit({
      files: [{ attachment: Buffer.from(response), name: "my_response.txt" }],
      content: `Whoopsies! The character count exceeded ${
        msg.client.user.premiumType === 2 ? "4000" : "2000"
      }, so here's a file with my response instead!`,
    });
  } else {
    console.log("Here");
    await sentMsg.edit(response);
  }
};

sendResponse(msg, "This is the update", tempSend)
/home/container/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:415
      throw new DiscordAPIError(data, res.status, request);
            ^
DiscordAPIError: Missing Permissions
    at RequestHandler.execute (/home/container/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:415:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RequestHandler.push (/home/container/node_modules/discord.js-selfbot-v13/src/rest/RequestHandler.js:63:14)
    at async MessageManager.edit (/home/container/node_modules/discord.js-selfbot-v13/src/managers/MessageManager.js:151:15) {
  method: 'patch',
  path: '/channels/1276647787253076022/messages/1276649177346084895',
  code: 50013,
  httpStatus: 403,
  requestData: {
    json: {
      activity: undefined,
      content: 'Error: ```js\nDiscordAPIError: Missing Permissions```',
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: { parse: [ 'users', 'roles' ], replied_user: false },
      flags: 0,
      message_reference: undefined,
      attachments: [],
      sticker_ids: undefined,
      thread_name: undefined,
      poll: undefined
    },
    files: [],
    headers: undefined
  },
  retries: 0,
  captcha: null
}
Node.js v19.9.0
[nodemon] app crashed - waiting for file changes before starting...
002-sans commented 2 weeks ago
1xChloe commented 2 weeks ago

yes here got logged, and it works, msg.client.user is the same as client.user when logged.

aiko-chan-ai commented 2 weeks ago

@1xChloe Based on the error message, this is an error from the Discord API, not a library error. You should check the necessary permissions (as recommended) and the code.