Skip to content

Commit

Permalink
fix(*): fix small typos
Browse files Browse the repository at this point in the history
  • Loading branch information
castdrian committed Jun 6, 2021
1 parent ce7127d commit c469257
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
30 changes: 13 additions & 17 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,17 +541,16 @@ class Message extends Base {

/**
* Edits the content of the message.
* @param {?(string|APIMessage)} [content] The new content for the message
* @param {MessageEditOptions|MessageEmbed|MessageAttachment|MessageAttachment[]} [options] The options to provide
* @param {MessageEditOptions|MessageEmbed|MessageAttachment|MessageAttachment[]} options The options to provide
* @returns {Promise<Message>}
* @example
* // Update the content of a message
* message.edit('This is my new content!')
* message.edit({ content: 'This is my new content!' })
* .then(msg => console.log(`Updated the content of a message to ${msg.content}`))
* .catch(console.error);
*/
edit(content, options) {
options = content instanceof APIMessage ? content : APIMessage.create(this, content, options);
edit(options) {
options = APIMessage.create(this, options.content, options);
return this.channel.messages.edit(this.id, options);
}

Expand Down Expand Up @@ -647,25 +646,22 @@ class Message extends Base {

/**
* Send an inline reply to this message.
* @param {string|APIMessage} [content=''] The content for the message
* @param {ReplyMessageOptions|MessageAdditions} [options] The additional options to provide
* @param {ReplyMessageOptions|MessageAdditions} options The additional options to provide
* @returns {Promise<Message|Message[]>}
* @example
* // Reply to a message
* message.reply('This is a reply!')
* message.reply({ content: 'This is a reply!' })
* .then(() => console.log(`Replied to message "${message.content}"`))
* .catch(console.error);
*/
reply(content, options) {
reply(options) {
return this.channel.send(
content instanceof APIMessage
? content
: APIMessage.transformOptions(content, options, {
reply: {
messageReference: this,
failIfNotExists: options?.failIfNotExists ?? content?.failIfNotExists ?? true,
},
}),
APIMessage.transformOptions(options.content, options, {
reply: {
messageReference: this,
failIfNotExists: options?.failIfNotExists ?? options.content?.failIfNotExists ?? true,
},
}),
);
}

Expand Down
15 changes: 2 additions & 13 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,20 +1254,9 @@ declare module 'discord.js' {
public pin(): Promise<Message>;
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
public removeAttachments(): Promise<Message>;
public reply(
content: string | null | (ReplyMessageOptions & { split?: false }) | MessageAdditions,
): Promise<Message>;
public reply(options: ReplyMessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
public reply(options: ReplyMessageOptions | APIMessage): Promise<Message | Message[]>;
public reply(
content: string | null,
options: (ReplyMessageOptions & { split?: false }) | MessageAdditions,
): Promise<Message>;
public reply(
content: string | null,
options: ReplyMessageOptions & { split: true | SplitOptions },
): Promise<Message[]>;
public reply(content: string | null, options: ReplyMessageOptions): Promise<Message | Message[]>;
public reply(options: ReplyMessageOptions): Promise<Message | Message[]>;
public reply(options: (ReplyMessageOptions & { split?: false }) | MessageAdditions): Promise<Message>;
public suppressEmbeds(suppress?: boolean): Promise<Message>;
public toJSON(): unknown;
public toString(): string;
Expand Down
2 changes: 1 addition & 1 deletion typings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare const assertIsMessage: (m: Promise<Message>) => void;
declare const assertIsMessageArray: (m: Promise<Message[]>) => void;

client.on('message', ({ channel }) => {
assertIsMessage(channel.send('string'));
assertIsMessage(channel.send({ content: 'string' }));
assertIsMessage(channel.send({}));
assertIsMessage(channel.send({ embed: {} }));

Expand Down

0 comments on commit c469257

Please sign in to comment.