refactor(APIRequest): utilize URLSearchParams (#3180)

* utilize URLSearchParams

* options.query can be undefined/null

* oops

* remembered what I intended
This commit is contained in:
bdistin
2019-04-05 04:32:19 -05:00
committed by SpaceEEC
parent c078682722
commit 5e9bd786d1
2 changed files with 15 additions and 7 deletions

View File

@@ -338,11 +338,15 @@ class Client extends BaseClient {
* .then(link => console.log(`Generated bot invite link: ${link}`))
* .catch(console.error);
*/
generateInvite(permissions) {
async generateInvite(permissions) {
permissions = Permissions.resolve(permissions);
return this.fetchApplication().then(application =>
`https://discordapp.com/oauth2/authorize?client_id=${application.id}&permissions=${permissions}&scope=bot`
);
const application = await this.fetchApplication();
const query = new URLSearchParams({
client_id: application.id,
permissions: permissions,
scope: 'bot',
});
return `${this.options.http.api}${this.api.oauth2.authorize}?${query}`;
}
toJSON() {