mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
@@ -49,11 +49,18 @@ class ClientPresence extends Presence {
|
||||
if (activities?.length) {
|
||||
for (const [i, activity] of activities.entries()) {
|
||||
if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string');
|
||||
activity.type ??= 0;
|
||||
|
||||
activity.type ??= ActivityTypes.PLAYING;
|
||||
|
||||
if (activity.type === ActivityType.CUSTOM && !activity.state) {
|
||||
activity.state = activity.name;
|
||||
activity.name = 'Custom Status';
|
||||
}
|
||||
|
||||
data.activities.push({
|
||||
type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type],
|
||||
name: activity.name,
|
||||
state: activity.state,
|
||||
url: activity.url,
|
||||
});
|
||||
}
|
||||
@@ -62,6 +69,7 @@ class ClientPresence extends Presence {
|
||||
...this.activities.map(a => ({
|
||||
name: a.name,
|
||||
type: ActivityTypes[a.type],
|
||||
state: activity.state ?? undefined,
|
||||
url: a.url ?? undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -96,7 +96,8 @@ class ClientUser extends User {
|
||||
/**
|
||||
* Options for setting activities
|
||||
* @typedef {Object} ActivitiesOptions
|
||||
* @property {string} [name] Name of the activity
|
||||
* @property {string} name Name of the activity
|
||||
* @property {string} [state] State of the activity
|
||||
* @property {ActivityType|number} [type] Type of the activity
|
||||
* @property {string} [url] Twitch / YouTube stream URL
|
||||
*/
|
||||
@@ -147,7 +148,7 @@ class ClientUser extends User {
|
||||
/**
|
||||
* Options for setting an activity.
|
||||
* @typedef {Object} ActivityOptions
|
||||
* @property {string} [name] Name of the activity
|
||||
* @property {string} name Name of the activity
|
||||
* @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
|
||||
@@ -155,7 +156,7 @@ class ClientUser extends User {
|
||||
|
||||
/**
|
||||
* Sets the activity the client user is playing.
|
||||
* @param {string|ActivityOptions} [name] Activity being played, or options for setting the activity
|
||||
* @param {string|ActivityOptions} name Activity being played, or options for setting the activity
|
||||
* @param {ActivityOptions} [options] Options for setting the activity
|
||||
* @returns {ClientPresence}
|
||||
* @example
|
||||
|
||||
7
typings/index.d.ts
vendored
7
typings/index.d.ts
vendored
@@ -708,7 +708,7 @@ export class ClientUser extends User {
|
||||
public verified: boolean;
|
||||
public edit(data: ClientUserEditData): Promise<this>;
|
||||
public setActivity(options?: ActivityOptions): ClientPresence;
|
||||
public setActivity(name: string, options?: ActivityOptions): ClientPresence;
|
||||
public setActivity(name: string, options?: Omit<ActivityOptions, 'name'>): ClientPresence;
|
||||
public setAFK(afk?: boolean, shardId?: number | number[]): ClientPresence;
|
||||
public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>;
|
||||
public setPresence(data: PresenceData): ClientPresence;
|
||||
@@ -3795,9 +3795,10 @@ export type ActivityFlagsString =
|
||||
export type ActivitiesOptions = Omit<ActivityOptions, 'shardId'>;
|
||||
|
||||
export interface ActivityOptions {
|
||||
name?: string;
|
||||
name: string;
|
||||
state?: string;
|
||||
url?: string;
|
||||
type?: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'>;
|
||||
type?: ActivityType;
|
||||
shardId?: number | readonly number[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user