From 989efb172e8434bbf262f79228967fb4b7fe5b71 Mon Sep 17 00:00:00 2001 From: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:36:55 -0400 Subject: [PATCH] feat: fetchMessages method --- src/common/shorters/channels.ts | 7 +++++++ src/common/shorters/messages.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/shorters/channels.ts b/src/common/shorters/channels.ts index 446d926..2789238 100644 --- a/src/common/shorters/channels.ts +++ b/src/common/shorters/channels.ts @@ -1,5 +1,6 @@ import { PermissionFlagsBits, + type RESTGetAPIChannelMessagesQuery, type RESTPatchAPIChannelJSONBody, type RESTPostAPIChannelThreadsJSONBody, type RESTPostAPIGuildForumThreadsJSONBody, @@ -176,6 +177,12 @@ export class ChannelShorter extends BaseShorter { permissions.add(roleOverwrites?.allow.bits ?? 0n); return permissions; } + + fetchMessages(channelId: string, query?: RESTGetAPIChannelMessagesQuery) { + return this.client.proxy.channels(channelId).messages.get({ + query, + }); + } } export type ChannelShorterOptionalParams = Partial<{ guildId: string; reason: string }>; diff --git a/src/common/shorters/messages.ts b/src/common/shorters/messages.ts index 993b777..5d941fa 100644 --- a/src/common/shorters/messages.ts +++ b/src/common/shorters/messages.ts @@ -24,6 +24,7 @@ export class MessageShorter extends BaseShorter { return new Message(this.client, message); }); } + async edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest) { const parsedFiles = files ? await resolveFiles(files) : []; return this.client.proxy @@ -45,6 +46,7 @@ export class MessageShorter extends BaseShorter { .crosspost.post({ reason }) .then(m => new Message(this.client, m)); } + delete(messageId: string, channelId: string, reason?: string) { return this.client.proxy .channels(channelId) @@ -54,6 +56,7 @@ export class MessageShorter extends BaseShorter { void this.client.components?.onMessageDelete(messageId); }); } + fetch(messageId: string, channelId: string) { return this.client.proxy .channels(channelId) @@ -61,11 +64,12 @@ export class MessageShorter extends BaseShorter { .get() .then(x => new Message(this.client, x)); } + purge(messages: string[], channelId: string, reason?: string) { return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason }); } - async thread( + thread( channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & { reason?: string },