From 73ed369eb018d9070ad0484e830a3a614598b6fe Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 19 Mar 2023 19:20:58 +0100 Subject: [PATCH 1/4] docs: differate user#send --- packages/discord.js/src/structures/User.js | 56 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index 75189c8c6dcb..de10f351a2ac 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -305,12 +305,60 @@ class User extends Base { json.bannerURL = this.banner ? this.bannerURL() : this.banner; return json; } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} } + +/** + * Sends a message to this user. + * @method send + * @memberof User + * @instance + * @param {string|MessagePayload|MessageCreateOptions} options The options to provide + * @returns {Promise} + * @example + * // Send a direct message + * user.send('hello!') + * .then(message => console.log(`Sent message: ${message.content}`)) + * .catch(console.error); + * @example + * // Send a remote file + * user.send({ + * files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048'] + * }) + * .then(console.log) + * .catch(console.error); + * @example + * // Send a local file + * user.send({ + * files: [{ + * attachment: 'entire/path/to/file.jpg', + * name: 'file.jpg', + * description: 'A description of the file' + * }] + * }) + * .then(console.log) + * .catch(console.error); + * @example + * // Send an embed with a local image inside + * user.send({ + * content: 'This is an embed', + * embeds: [ + * { + * thumbnail: { + * url: 'attachment://file.jpg' + * } + * } + * ], + * files: [{ + * attachment: 'entire/path/to/file.jpg', + * name: 'file.jpg', + * description: 'A description of the file' + * }] + * }) + * .then(console.log) + * .catch(console.error); + */ + TextBasedChannel.applyToClass(User); module.exports = User; From aee93a50200c02bf4707d12fa994baf3b066650f Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 19 Mar 2023 19:44:20 +0100 Subject: [PATCH 2/4] chore: format --- packages/discord.js/src/structures/User.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index de10f351a2ac..57ccc2e9396f 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -307,7 +307,6 @@ class User extends Base { } } - /** * Sends a message to this user. * @method send From 4705d66e18eb5b47af15457ec8ea0c553709f388 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Mon, 20 Mar 2023 20:00:29 +0100 Subject: [PATCH 3/4] chore: remove some examples --- packages/discord.js/src/structures/User.js | 41 +------------------ .../structures/interfaces/TextBasedChannel.js | 19 --------- 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index 57ccc2e9396f..c784e4e95eb4 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -316,45 +316,8 @@ class User extends Base { * @returns {Promise} * @example * // Send a direct message - * user.send('hello!') - * .then(message => console.log(`Sent message: ${message.content}`)) - * .catch(console.error); - * @example - * // Send a remote file - * user.send({ - * files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048'] - * }) - * .then(console.log) - * .catch(console.error); - * @example - * // Send a local file - * user.send({ - * files: [{ - * attachment: 'entire/path/to/file.jpg', - * name: 'file.jpg', - * description: 'A description of the file' - * }] - * }) - * .then(console.log) - * .catch(console.error); - * @example - * // Send an embed with a local image inside - * user.send({ - * content: 'This is an embed', - * embeds: [ - * { - * thumbnail: { - * url: 'attachment://file.jpg' - * } - * } - * ], - * files: [{ - * attachment: 'entire/path/to/file.jpg', - * name: 'file.jpg', - * description: 'A description of the file' - * }] - * }) - * .then(console.log) + * user.send('Hello!') + * .then(message => console.log(`Sent message: ${message.content} to ${user.tag}`)) * .catch(console.error); */ diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js index 2c73ffc9cb69..d8562f81a433 100644 --- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js +++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js @@ -135,25 +135,6 @@ class TextBasedChannel { * }) * .then(console.log) * .catch(console.error); - * @example - * // Send an embed with a local image inside - * channel.send({ - * content: 'This is an embed', - * embeds: [ - * { - * thumbnail: { - * url: 'attachment://file.jpg' - * } - * } - * ], - * files: [{ - * attachment: 'entire/path/to/file.jpg', - * name: 'file.jpg', - * description: 'A description of the file' - * }] - * }) - * .then(console.log) - * .catch(console.error); */ async send(options) { const User = require('../User'); From 12d7048c00d0557a6f1d976b37879de729991b01 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Thu, 23 Mar 2023 20:19:27 +0100 Subject: [PATCH 4/4] docs: add GuildMember#send example --- .../discord.js/src/structures/GuildMember.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/structures/GuildMember.js b/packages/discord.js/src/structures/GuildMember.js index f6d10d1f3e2f..289227bfdc17 100644 --- a/packages/discord.js/src/structures/GuildMember.js +++ b/packages/discord.js/src/structures/GuildMember.js @@ -472,12 +472,22 @@ class GuildMember extends Base { json.displayAvatarURL = this.displayAvatarURL(); return json; } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} } +/** + * Sends a message to this user. + * @method send + * @memberof GuildMember + * @instance + * @param {string|MessagePayload|MessageCreateOptions} options The options to provide + * @returns {Promise} + * @example + * // Send a direct message + * guildMember.send('Hello!') + * .then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`)) + * .catch(console.error); + */ + TextBasedChannel.applyToClass(GuildMember); exports.GuildMember = GuildMember;