Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make changes to PresenceData typings and docs #5317

Merged
merged 6 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/structures/ClientUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ class ClientUser extends Structures.get('User') {
return this.edit({ avatar: await DataResolver.resolveImage(avatar) });
}

/**
* Options for setting activities
* @typedef {Object} ActivitiesOptions
* @property {string} [name] Name of the activity
* @property {ActivityType|number} [type] Type of the activity
* @property {string} [url] Twitch / YouTube stream URL
*/

/**
* Data resembling a raw Discord presence.
* @typedef {Object} PresenceData
* @property {PresenceStatusData} [status] Status of the user
* @property {boolean} [afk] Whether the user is AFK
* @property {Object} [activity] Activity the user is playing
* @property {string} [activity.name] Name of the activity
* @property {ActivityType|number} [activity.type] Type of the activity
* @property {string} [activity.url] Twitch / YouTube stream URL
* @property {ActivitiesOptions[]} [activities] Activity the user is playing
* @property {?number|number[]} [shardID] Shard Id(s) to have the activity set on
*/

Expand All @@ -108,7 +113,7 @@ class ClientUser extends Structures.get('User') {
* @returns {Presence}
* @example
* // Set the client user's presence
* client.user.setPresence({ activity: { name: 'with discord.js' }, status: 'idle' })
* client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' })
* .then(console.log)
* .catch(console.error);
*/
Expand Down Expand Up @@ -144,6 +149,7 @@ class ClientUser extends Structures.get('User') {
* Options for setting an activity.
* @typedef ActivityOptions
* @type {Object}
* @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
Expand Down
12 changes: 7 additions & 5 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,12 @@ declare module 'discord.js' {

type ActivityFlagsString = 'INSTANCE' | 'JOIN' | 'SPECTATE' | 'JOIN_REQUEST' | 'SYNC' | 'PLAY';

interface ActivitiesOptions {
name?: string;
url?: string;
type?: ActivityType | number;
}
iShibi marked this conversation as resolved.
Show resolved Hide resolved

interface ActivityOptions {
name?: string;
url?: string;
Expand Down Expand Up @@ -3062,11 +3068,7 @@ declare module 'discord.js' {
interface PresenceData {
status?: PresenceStatusData;
afk?: boolean;
activity?: {
name?: string;
type?: ActivityType | number;
url?: string;
};
activities?: ActivitiesOptions[];
shardID?: number | number[];
}

Expand Down