Skip to content

Commit 2c86024

Browse files
committed
chore: post json body
1 parent e7f6f80 commit 2c86024

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/managers/GuildMemberManager.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,23 @@ class GuildMemberManager extends BaseManager {
162162

163163
for (const role of roles) {
164164
const resolvedRole = this.guild.roles.resolveID(role);
165+
if (!resolvedRole) {
166+
return Promise.reject(new TypeError('INVALID_TYPE', 'roles', 'Array of Roles or Snowflakes', true));
167+
}
165168
if (resolvedRole) query.append('include_roles', role);
166169
}
167170

168-
return this.client.api
169-
.guilds(this.guild.id)
170-
.prune[dry ? 'get' : 'post']({
171-
query,
172-
reason,
173-
})
174-
.then(data => data.pruned);
171+
const endpoint = this.client.api.guilds(this.guild.id).prune;
172+
173+
if (dry) {
174+
return endpoint.get({ query, reason }).then(data => data.pruned);
175+
} else {
176+
const body = [...query.entries()].reduce((acc, [k, v]) => {
177+
acc[k] = v;
178+
return acc;
179+
}, {});
180+
return endpoint.post(body).then(data => data.pruned);
181+
}
175182
}
176183

177184
/**

0 commit comments

Comments
 (0)