Skip to content

Conversation

Jiralite
Copy link
Member

@Jiralite Jiralite commented Jun 8, 2024

Please describe the changes this PR makes and why it should be merged:
Resolves #10337 by checking for an ArrayBuffer instead.

I was also able to reproduce an empty array buffer response instead of a Uint8Array. The trace verifies this:

Trace: 
    at parseResponse (/Users/jiralite/Documents/code/GitHub/discordjs/discord.js/packages/rest/src/lib/utils/utils.ts:59:10)
    at _REST.request (/Users/jiralite/Documents/code/GitHub/discordjs/discord.js/packages/rest/src/lib/REST.ts:211:10)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at GuildMemberManager.add (/Users/jiralite/Documents/code/GitHub/discordjs/discord.js/packages/discord.js/src/managers/GuildMemberManager.js:130:18)
    at Client.<anonymous> (file:///Users/jiralite/Documents/code/GitHub/Soulobby/Soulobby/test.ts:16:14)

export async function parseResponse(res: ResponseLike): Promise<unknown> {
if (res.headers.get('Content-Type')?.startsWith('application/json')) {
return res.json();
}
return res.arrayBuffer();
}

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Copy link

vercel bot commented Jun 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jun 29, 2024 6:44am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jun 29, 2024 6:44am

@kodiakhq kodiakhq bot merged commit ab8bf0f into main Jun 29, 2024
@kodiakhq kodiakhq bot deleted the fix/add-empty branch June 29, 2024 06:48
vladfrangu pushed a commit that referenced this pull request Jan 1, 2025
fix(GuildMemberManager): fix data type check

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Uncaught exception when adding member that is already part of the guild

4 participants