Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GuildMemberManager): Fix data type check for add() method #10338

Merged
merged 4 commits into from
Jun 29, 2024

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
8 checks passed
@kodiakhq kodiakhq bot deleted the fix/add-empty branch June 29, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

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