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): options.roles on 'prune' #4838

Merged
merged 1 commit into from
Oct 17, 2020

Conversation

izexi
Copy link
Contributor

@izexi izexi commented Sep 21, 2020

Since 257371d was merged, it allowed an array of values to be passed through a query's value (as explained here). f1194af did not accommodate for these changes that were committed beforehand to make include_roles=foo&include_roles=bar possible.

As of discord/discord-api-docs@b9edace#diff-c4e1390fca89ecc96b01a093f988fa1cR720 Discord now accepts a "comma-delimited array of snowflakes"... but the old key=value&key=value still works (and is even being used in the client). This PR changes the prune method to pass comma-delimited array of role IDs for options.roles since that is what is currently documented. The code within the APIRequest class hasn't been changed for more compatibility (incase Discord decides to add or change another query that accepts the key=value&key=value format). compute_prune_count is also excluded from the GET request for the prune in this PR, since that isn't being used.

Fixes #4834

Here's a snippet of how I tested these changes
import { once } from 'events';
import { Client } from 'discord.js';
import { TEST_GUILD_ID, TEST_ROLE_IDS, TOKEN } from './constants';

const client = new Client();
// verified through the client
const EXPECTED_NUMBER = 6;

client.login(TOKEN);

test('GuildMemberManager#prune() with options.roles', async () => {
  await once(client, 'ready');

  const { members } = client.guilds.cache.get(TEST_GUILD_ID);

  // GET
  expect(
    members.prune({
      days: 30,
      roles: TEST_ROLE_IDS,
      dry: true,
    })
  ).resolves.toBe(EXPECTED_NUMBER);

  // POST
  expect(
    members.prune({
      days: 30,
      roles: TEST_ROLE_IDS,
    })
  ).resolves.toBe(EXPECTED_NUMBER);
});

Status

  • 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

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@iCrawl iCrawl merged commit a45cc11 into discordjs:master Oct 17, 2020
@izexi izexi deleted the fix-prune branch October 17, 2020 14:16
GiorgioBrux pushed a commit to GiorgioBrux/discord.js that referenced this pull request Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with <guild>.members.prune()
6 participants