Skip to content

Commit

Permalink
feat(MessageManager): #fetch accept MessageResolvable
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman1s committed May 30, 2022
1 parent 22416a2 commit d1c0967
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/managers/MessageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ export class MessageManager extends BaseManager<Message, APIMessage> {
}, new Collection<string, Message>());
}

fetch(messageId: string): Promise<Message>;
fetch(message: MessageResolvable): Promise<Message>;
fetch(query: MessageQueryOptions): Promise<Collection<string, Message>>;
fetch(limit: number): Promise<Collection<string, Message>>;
async fetch(
query?: string | MessageQueryOptions | number,
query?: MessageResolvable | MessageQueryOptions | number,
): Promise<Collection<string, Message> | Message> {
if (typeof query === 'string') {
const id = this.resolveId(query as string);

if (id) {
const data = await this.client.api.get(
`/channels/${this.channel.id}/messages/${query}`,
`/channels/${this.channel.id}/messages/${id}`,
) as APIMessage;
return this._add(data);
}
Expand Down

0 comments on commit d1c0967

Please sign in to comment.