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}
* @example
* // Logs: Application name: My App
* console.log(`Application name: ${application}`);
*/
toString() {
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
* DM channel object.
* When concatenated with a string, this automatically returns the recipient's mention instead of the
* DMChannel object.
* @returns {string}
* @example
* // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${channel}!`);
*/
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}
* @example
* // 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}
* @example
* // Logs: Hello from My Group DM!
* console.log(`Hello from ${channel}!`);
* @example
* // Logs: Hello from My Group DM!
* console.log(`Hello from ' + channel + '!');
*/
toString() {
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}
* @example
* // Logs: Hello from My Guild!
* console.log(`Hello from ${guild}!`);
* @example
* // Logs: Hello from My Guild!
* console.log('Hello from ' + guild + '!');
*/
toString() {
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.
* @returns {string}
* @example
* // Outputs: Hello from #general
* console.log(`Hello from ${channel}`);
* @example
* // Outputs: Hello from #general
* console.log('Hello from ' + channel);
* // Logs: Hello from <#123456789012345678>!
* console.log(`Hello from ${channel}!`);
*/
toString() {
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}
* @example
* // Logs: Hello from <@123456789>!
* // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${member}!`);
*/
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
* // 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}`);
* @returns {string}
* reaction.message.channel.send(`The emoji used was: ${reaction.emoji}`);
*/
toString() {
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}
* @example
* // Logs: Role: <@&123456789012345678>
* console.log(`Role: ${role}`);
*/
toString() {
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}
* @example
* // logs: Hello from <@123456789>!
* // Logs: Hello from <@123456789012345678>!
* console.log(`Hello from ${user}!`);
*/
toString() {