refactor: switch api and gateway to V8 (#4879)

Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
This commit is contained in:
Sugden
2021-02-11 17:10:35 +00:00
committed by GitHub
parent ae3c3d80ee
commit ee5bc1a5c4
33 changed files with 372 additions and 364 deletions

View File

@@ -46,16 +46,18 @@ class ClientUser extends Structures.get('User') {
return this.client.presence;
}
edit(data) {
return this.client.api
.users('@me')
.patch({ data })
.then(newData => {
this.client.token = newData.token;
const { updated } = this.client.actions.UserUpdate.handle(newData);
if (updated) return updated;
return this;
});
/**
* Edits the logged in client.
* @param {Object} data The new data
* @param {string} [data.username] The new username
* @param {BufferResolvable|Base64Resolvable} [data.avatar] The new avatar
*/
async edit(data) {
const newData = await this.client.api.users('@me').patch({ data });
this.client.token = newData.token;
const { updated } = this.client.actions.UserUpdate.handle(newData);
if (updated) return updated;
return this;
}
/**
@@ -103,7 +105,7 @@ class ClientUser extends Structures.get('User') {
/**
* Sets the full presence of the client user.
* @param {PresenceData} data Data for the presence
* @returns {Promise<Presence>}
* @returns {Presence}
* @example
* // Set the client user's presence
* client.user.setPresence({ activity: { name: 'with discord.js' }, status: 'idle' })
@@ -127,7 +129,7 @@ class ClientUser extends Structures.get('User') {
* Sets the status of the client user.
* @param {PresenceStatusData} status Status to change to
* @param {?number|number[]} [shardID] Shard ID(s) to have the activity set on
* @returns {Promise<Presence>}
* @returns {Presence}
* @example
* // Set the client user's status
* client.user.setStatus('idle')
@@ -144,14 +146,14 @@ class ClientUser extends Structures.get('User') {
* @type {Object}
* @property {string} [url] Twitch / YouTube stream URL
* @property {ActivityType|number} [type] Type of the activity
* @property {?number|number[]} [shardID] Shard Id(s) to have the activity set on
* @property {number|number[]} [shardID] Shard Id(s) to have the activity set on
*/
/**
* Sets the activity the client user is playing.
* @param {string|ActivityOptions} [name] Activity being played, or options for setting the activity
* @param {ActivityOptions} [options] Options for setting the activity
* @returns {Promise<Presence>}
* @returns {Presence}
* @example
* // Set the client user's activity
* client.user.setActivity('discord.js', { type: 'WATCHING' })
@@ -159,19 +161,20 @@ class ClientUser extends Structures.get('User') {
* .catch(console.error);
*/
setActivity(name, options = {}) {
if (!name) return this.setPresence({ activity: null, shardID: options.shardID });
if (!name) return this.setPresence({ activities: null, shardID: options.shardID });
const activity = Object.assign({}, options, typeof name === 'object' ? name : { name });
return this.setPresence({ activity, shardID: activity.shardID });
return this.setPresence({ activities: [activity], shardID: activity.shardID });
}
/**
* Sets/removes the AFK flag for the client user.
* @param {boolean} afk Whether or not the user is AFK
* @returns {Promise<Presence>}
* @param {number|number[]} [shardID] Shard Id(s) to have the AFK flag set on
* @returns {Presence}
*/
setAFK(afk) {
return this.setPresence({ afk });
setAFK(afk, shardID) {
return this.setPresence({ afk, shardID });
}
}