mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
featt(ClientUser): allow options as first parameter to setActivity (#2890)
This commit is contained in:
@@ -97,7 +97,7 @@ class ClientUser extends Structures.get('User') {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPresence(data) {
|
||||
return this.client.presence.setClientPresence(data);
|
||||
return this.client.presence.set(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,12 +123,18 @@ class ClientUser extends Structures.get('User') {
|
||||
return this.setPresence({ status });
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for setting an activity
|
||||
* @typedef ActivityOptions
|
||||
* @type {Object}
|
||||
* @property {string} [url] Twitch stream URL
|
||||
* @property {ActivityType|number} [type] Type of the activity
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the activity the client user is playing.
|
||||
* @param {?string} name Activity being played
|
||||
* @param {Object} [options] Options for setting the activity
|
||||
* @param {string} [options.url] Twitch stream URL
|
||||
* @param {ActivityType|number} [options.type] Type of the activity
|
||||
* @param {string|ActivityOptions} [name] Activity being played, or options for setting the activity
|
||||
* @param {ActivityOptions} [options] Options for setting the activity
|
||||
* @returns {Promise<Presence>}
|
||||
* @example
|
||||
* // Set the client user's activity
|
||||
@@ -136,11 +142,11 @@ class ClientUser extends Structures.get('User') {
|
||||
* .then(presence => console.log(`Activity set to ${presence.game.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setActivity(name, { url, type } = {}) {
|
||||
setActivity(name, options = {}) {
|
||||
if (!name) return this.setPresence({ activity: null });
|
||||
return this.setPresence({
|
||||
activity: { name, type, url },
|
||||
});
|
||||
|
||||
const activity = Object.assign({}, options, typeof name === 'object' ? name : { name });
|
||||
return this.setPresence({ activity });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user