docs: document constructors of extendible structures (#3160)

* docs: document constructors of extendible structures

* docs(ClientPresence): document default value for data parameter

Co-Authored-By: SpaceEEC <spaceeec@yahoo.com>

* docs(Presence): document default value for data parameter

Co-Authored-By: SpaceEEC <spaceeec@yahoo.com>

* docs(DMChannel): capitalize DM in the constructor doc
This commit is contained in:
SpaceEEC
2019-04-14 14:50:55 +02:00
committed by GitHub
parent 5d10585af8
commit ca43919642
14 changed files with 58 additions and 1 deletions

View File

@@ -6,6 +6,10 @@ const { ActivityTypes, OPCodes } = require('../util/Constants');
const { TypeError } = require('../errors');
class ClientPresence extends Presence {
/**
* @param {Client} client The instantiating client
* @param {Object} [data={}] The data for the client presence
*/
constructor(client, data = {}) {
super(client, Object.assign(data, { status: 'online', user: { id: null } }));
}

View File

@@ -10,6 +10,10 @@ const MessageStore = require('../stores/MessageStore');
* @implements {TextBasedChannel}
*/
class DMChannel extends Channel {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the DM channel
*/
constructor(client, data) {
super(client, data);
// Override the channel type so partials have a known type

View File

@@ -26,6 +26,10 @@ const { Error, TypeError } = require('../errors');
* @extends {Base}
*/
class Guild extends Base {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the guild
*/
constructor(client, data) {
super(client);

View File

@@ -14,6 +14,10 @@ const { Error, TypeError } = require('../errors');
* @extends {Channel}
*/
class GuildChannel extends Channel {
/**
* @param {Guild} guild The guild the guild channel is part of
* @param {Object} data The data for the guild channel
*/
constructor(guild, data) {
super(guild.client, data);

View File

@@ -10,6 +10,11 @@ const Emoji = require('./Emoji');
* @extends {Emoji}
*/
class GuildEmoji extends Emoji {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the guild emoji
* @param {Guild} guild The guild the guild emoji is part of
*/
constructor(client, data, guild) {
super(client, data);

View File

@@ -15,6 +15,11 @@ const { Error } = require('../errors');
* @extends {Base}
*/
class GuildMember extends Base {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the guild member
* @param {Guild} guild The guild the member is part of
*/
constructor(client, data, guild) {
super(client);

View File

@@ -19,6 +19,11 @@ const APIMessage = require('./APIMessage');
* @extends {Base}
*/
class Message extends Base {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the message
* @param {TextChannel|DMChannel} channel The channel the message was sent in
*/
constructor(client, data, channel) {
super(client);

View File

@@ -9,6 +9,11 @@ const ReactionUserStore = require('../stores/ReactionUserStore');
* Represents a reaction to a message.
*/
class MessageReaction {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the message reaction
* @param {Message} message The message the reaction refers to
*/
constructor(client, data, message) {
/**
* The message that this reaction refers to

View File

@@ -25,6 +25,10 @@ const { ActivityTypes } = require('../util/Constants');
* Represents a user's presence.
*/
class Presence {
/**
* @param {Client} client The instantiating client
* @param {Object} [data={}] The data for the presence
*/
constructor(client, data = {}) {
Object.defineProperty(this, 'client', { value: client });
/**

View File

@@ -11,6 +11,11 @@ const { Error, TypeError } = require('../errors');
* @extends {Base}
*/
class Role extends Base {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the role
* @param {Guild} guild The guild the role is part of
*/
constructor(client, data, guild) {
super(client);

View File

@@ -13,6 +13,10 @@ const MessageStore = require('../stores/MessageStore');
* @implements {TextBasedChannel}
*/
class TextChannel extends GuildChannel {
/**
* @param {Guild} guild The guild the text channel is part of
* @param {Object} data The data for the text channel
*/
constructor(guild, data) {
super(guild, data);
/**

View File

@@ -12,6 +12,10 @@ const { Error } = require('../errors');
* @extends {Base}
*/
class User extends Base {
/**
* @param {Client} client The instantiating client
* @param {Object} data The data for the user
*/
constructor(client, data) {
super(client);

View File

@@ -6,6 +6,10 @@ const Base = require('./Base');
* Represents the voice state for a Guild Member.
*/
class VoiceState extends Base {
/**
* @param {Guild} guild The guild the voice state is part of
* @param {Object} data The data for the voice state
*/
constructor(guild, data) {
super(guild.client);
/**

2
typings/index.d.ts vendored
View File

@@ -809,7 +809,7 @@ declare module 'discord.js' {
}
export class Presence {
constructor(client: Client, data?: object);
constructor(client: Client, data: object);
public activity: Activity;
public flags: Readonly<ActivityFlags>;
public status: PresenceStatus;