docs: Add/normalize .toString() docs on all classes (#2042)

* docs: Add/normalize .toString() examples on all classes

* docs: Remove exclamation point on ClientApplication#toString example

* docs: Normalize .toString() descriptions on all classes

* Use "returns" instead of "concatenates"
This commit is contained in:
Sanctuary
2017-10-28 14:06:26 -03:00
committed by Crawl
parent 0101392334
commit 1a8e8c7a67
10 changed files with 28 additions and 25 deletions

View File

@@ -195,8 +195,12 @@ class ClientApplication extends Base {
} }
/** /**
* When concatenated with a string, this automatically concatenates the app name rather than the app object. * When concatenated with a string, this automatically returns the application's name instead of the
* ClientApplication object.
* @returns {string} * @returns {string}
* @example
* // Logs: Application name: My App
* console.log(`Application name: ${application}`);
*/ */
toString() { toString() {
return this.name; return this.name;

View File

@@ -27,9 +27,12 @@ class DMChannel extends Channel {
} }
/** /**
* When concatenated with a string, this automatically concatenates the recipient's mention instead of the * When concatenated with a string, this automatically returns the recipient's mention instead of the
* DM channel object. * DMChannel object.
* @returns {string} * @returns {string}
* @example
* // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${channel}!`);
*/ */
toString() { toString() {
return this.recipient.toString(); return this.recipient.toString();

View File

@@ -190,7 +190,7 @@ class Emoji extends Base {
} }
/** /**
* When concatenated with a string, this automatically returns the emoji mention rather than the object. * When concatenated with a string, this automatically concatenates the emoji's mention instead of the Emoji object.
* @returns {string} * @returns {string}
* @example * @example
* // Send an emoji: * // Send an emoji:

View File

@@ -203,14 +203,12 @@ class GroupDMChannel extends Channel {
} }
/** /**
* When concatenated with a string, this automatically concatenates the channel's name instead of the Channel object. * When concatenated with a string, this automatically returns the channel's name instead of the
* GroupDMChannel object.
* @returns {string} * @returns {string}
* @example * @example
* // Logs: Hello from My Group DM! * // Logs: Hello from My Group DM!
* console.log(`Hello from ${channel}!`); * console.log(`Hello from ${channel}!`);
* @example
* // Logs: Hello from My Group DM!
* console.log(`Hello from ' + channel + '!');
*/ */
toString() { toString() {
return this.name; return this.name;

View File

@@ -1123,14 +1123,11 @@ class Guild extends Base {
} }
/** /**
* When concatenated with a string, this automatically concatenates the guild's name instead of the guild object. * When concatenated with a string, this automatically returns the guild's name instead of the Guild object.
* @returns {string} * @returns {string}
* @example * @example
* // Logs: Hello from My Guild! * // Logs: Hello from My Guild!
* console.log(`Hello from ${guild}!`); * console.log(`Hello from ${guild}!`);
* @example
* // Logs: Hello from My Guild!
* console.log('Hello from ' + guild + '!');
*/ */
toString() { toString() {
return this.name; return this.name;

View File

@@ -493,11 +493,8 @@ class GuildChannel extends Channel {
* When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. * When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
* @returns {string} * @returns {string}
* @example * @example
* // Outputs: Hello from #general * // Logs: Hello from <#123456789012345678>!
* console.log(`Hello from ${channel}`); * console.log(`Hello from ${channel}!`);
* @example
* // Outputs: Hello from #general
* console.log('Hello from ' + channel);
*/ */
toString() { toString() {
return `<#${this.id}>`; return `<#${this.id}>`;

View File

@@ -529,10 +529,10 @@ class GuildMember extends Base {
} }
/** /**
* When concatenated with a string, this automatically concatenates the user's mention instead of the Member object. * When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
* @returns {string} * @returns {string}
* @example * @example
* // Logs: Hello from <@123456789>! * // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${member}!`); * console.log(`Hello from ${member}!`);
*/ */
toString() { toString() {

View File

@@ -35,11 +35,12 @@ class ReactionEmoji {
} }
/** /**
* Creates the text required to form a graphical emoji on Discord. * When concatenated with a string, this automatically returns the text required to form a graphical emoji on Discord
* instead of the ReactionEmoji object.
* @returns {string}
* @example * @example
* // Send the emoji used in a reaction to the channel the reaction is part of * // Send the emoji used in a reaction to the channel the reaction is part of
* reaction.message.channel.send(`The emoji used is ${reaction.emoji}`); * reaction.message.channel.send(`The emoji used was: ${reaction.emoji}`);
* @returns {string}
*/ */
toString() { toString() {
return this.id ? `<:${this.name}:${this.id}>` : this.name; return this.id ? `<:${this.name}:${this.id}>` : this.name;

View File

@@ -332,8 +332,11 @@ class Role extends Base {
} }
/** /**
* When concatenated with a string, this automatically concatenates the role mention rather than the Role object. * When concatenated with a string, this automatically returns the role's mention instead of the Role object.
* @returns {string} * @returns {string}
* @example
* // Logs: Role: <@&123456789012345678>
* console.log(`Role: ${role}`);
*/ */
toString() { toString() {
if (this.id === this.guild.id) return '@everyone'; if (this.id === this.guild.id) return '@everyone';

View File

@@ -248,10 +248,10 @@ class User extends Base {
} }
/** /**
* When concatenated with a string, this automatically concatenates the user's mention instead of the User object. * When concatenated with a string, this automatically returns the user's mention instead of the User object.
* @returns {string} * @returns {string}
* @example * @example
* // logs: Hello from <@123456789>! * // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${user}!`); * console.log(`Hello from ${user}!`);
*/ */
toString() { toString() {