mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 16:52:16 +00:00
Add setStatus function
This commit is contained in:
parent
dd40b870d5
commit
8fed1b1d80
1 changed files with 38 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ class ClientUser extends User {
|
||||||
setPassword(password) {
|
setPassword(password) {
|
||||||
return this.client.rest.methods.updateCurrentUser({ password });
|
return this.client.rest.methods.updateCurrentUser({ password });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the avatar of the logged in Client.
|
* Set the avatar of the logged in Client.
|
||||||
* @param {Base64Resolvable} avatar the new avatar
|
* @param {Base64Resolvable} avatar the new avatar
|
||||||
|
|
@ -78,6 +79,43 @@ class ClientUser extends User {
|
||||||
return this.client.rest.methods.updateCurrentUser({ avatar });
|
return this.client.rest.methods.updateCurrentUser({ avatar });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the playing status of the logged in client.
|
||||||
|
* @param {String} status
|
||||||
|
* @param {String} game
|
||||||
|
* @returns {Promise<ClientUser>}
|
||||||
|
* @example
|
||||||
|
* // set status
|
||||||
|
* client.user.setStatus('status', 'game')
|
||||||
|
* .then(user => console.log('Changed status!'))
|
||||||
|
* .catch(console.log);
|
||||||
|
*/
|
||||||
|
setStatus(status, game) {
|
||||||
|
if (status === "online" || status === "here" || status === "available") {
|
||||||
|
this.idleStatus = null;
|
||||||
|
} else if (status === "idle" || status === "away") {
|
||||||
|
this.idleStatus = Date.now();
|
||||||
|
} else {
|
||||||
|
this.idleStatus = this.idleStatus || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof game === "string" && !game.length) game = null;
|
||||||
|
this.userGame = game === null ? null : !game ? this.userGame || null : typeof game === "string" ? {name: game} : game;
|
||||||
|
|
||||||
|
this.client.ws.send({
|
||||||
|
op: 3,
|
||||||
|
d: {
|
||||||
|
idle_since: this.idleStatus,
|
||||||
|
game: this.userGame
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.status = this.idleStatus ? "idle" : "online";
|
||||||
|
this.game = this.userGame;
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
edit(data) {
|
edit(data) {
|
||||||
return this.client.rest.methods.updateCurrentUser(data);
|
return this.client.rest.methods.updateCurrentUser(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue