mirror of
https://github.com/danbulant/discord.js
synced 2026-06-20 07:02:00 +00:00
Webpack build for branch master: 48be401330
This commit is contained in:
parent
f25a09deff
commit
fe0f0ce7c4
2 changed files with 30 additions and 3 deletions
|
|
@ -9302,6 +9302,14 @@ class ClientUser extends User {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Invite|string} invite Invite or code to accept
|
||||
* @returns {Promise<Guild>} Joined guild
|
||||
*/
|
||||
acceptInvite(invite) {
|
||||
return this.client.rest.methods.acceptInvite(invite);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientUser;
|
||||
|
|
@ -22887,6 +22895,25 @@ class RESTMethods {
|
|||
setNote(user, note) {
|
||||
return this.rest.makeRequest('put', Constants.Endpoints.note(user.id), true, { note }).then(() => user);
|
||||
}
|
||||
|
||||
acceptInvite(code) {
|
||||
if (code.id) code = code.id;
|
||||
return new Promise((resolve, reject) =>
|
||||
this.rest.makeRequest('post', Constants.Endpoints.invite(code), true).then((res) => {
|
||||
const handler = guild => {
|
||||
if (guild.id === res.id) {
|
||||
resolve(guild);
|
||||
this.client.removeListener('guildCreate', handler);
|
||||
}
|
||||
};
|
||||
this.client.on('guildCreate', handler);
|
||||
this.client.setTimeout(() => {
|
||||
this.client.removeListener('guildCreate', handler);
|
||||
reject(new Error('Accepting invite timed out'));
|
||||
}, 120e3);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
|
|
|||
6
discord.master.min.js
vendored
6
discord.master.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue