This commit is contained in:
MARCROCK22 2024-11-16 20:59:59 -04:00
commit fd7c116215
2 changed files with 13 additions and 4 deletions

View File

@ -1,13 +1,14 @@
import { resolveFiles } from '../../builders'; import { resolveFiles } from '../../builders';
import { MessagesMethods } from '../../structures'; import { MessagesMethods } from '../../structures';
import type { import type {
RESTGetAPIChannelMessagesQuery,
RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIChannelMessageJSONBody,
RESTPostAPIChannelMessageJSONBody, RESTPostAPIChannelMessageJSONBody,
RESTPostAPIChannelMessagesThreadsJSONBody, RESTPostAPIChannelMessagesThreadsJSONBody,
} from '../../types'; } from '../../types';
import type { ValidAnswerId } from '../../api/Routes/channels'; import type { ValidAnswerId } from '../../api/Routes/channels';
import { Transformers } from '../../client/transformers'; import { Transformers } from '../../client';
import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write'; import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
import { BaseShorter } from './base'; import { BaseShorter } from './base';
@ -111,4 +112,11 @@ export class MessageShorter extends BaseShorter {
.get() .get()
.then(data => data.users.map(user => Transformers.User(this.client, user))); .then(data => data.users.map(user => Transformers.User(this.client, user)));
} }
list(channelId: string, fetchOptions: RESTGetAPIChannelMessagesQuery) {
return this.client.proxy
.channels(channelId)
.messages.get({ query: fetchOptions })
.then(messages => messages.map(message => Transformers.Message(this.client, message)));
}
} }

View File

@ -15,7 +15,7 @@ import {
type ThreadChannelStructure, type ThreadChannelStructure,
Transformers, Transformers,
type VoiceChannelStructure, type VoiceChannelStructure,
} from '../client/transformers'; } from '../client';
import type { UsingClient } from '../commands'; import type { UsingClient } from '../commands';
import type { import type {
EmojiResolvable, EmojiResolvable,
@ -45,6 +45,7 @@ import {
ChannelType, ChannelType,
type RESTAPIAttachment, type RESTAPIAttachment,
type RESTGetAPIChannelMessageReactionUsersQuery, type RESTGetAPIChannelMessageReactionUsersQuery,
type RESTGetAPIChannelMessagesQuery,
type RESTPatchAPIChannelJSONBody, type RESTPatchAPIChannelJSONBody,
type RESTPatchAPIGuildChannelPositionsJSONBody, type RESTPatchAPIGuildChannelPositionsJSONBody,
type RESTPostAPIChannelWebhookJSONBody, type RESTPostAPIChannelWebhookJSONBody,
@ -253,6 +254,7 @@ export class MessagesMethods extends DiscordBase {
delete: (messageId: string, reason?: string) => ctx.client.messages.delete(messageId, ctx.channelId, reason), delete: (messageId: string, reason?: string) => ctx.client.messages.delete(messageId, ctx.channelId, reason),
fetch: (messageId: string) => ctx.client.messages.fetch(messageId, ctx.channelId), fetch: (messageId: string) => ctx.client.messages.fetch(messageId, ctx.channelId),
purge: (messages: string[], reason?: string) => ctx.client.messages.purge(messages, ctx.channelId, reason), purge: (messages: string[], reason?: string) => ctx.client.messages.purge(messages, ctx.channelId, reason),
list: (fetchOptions: RESTGetAPIChannelMessagesQuery) => ctx.client.messages.list(ctx.channelId, fetchOptions),
}; };
} }
@ -406,8 +408,7 @@ export class VoiceChannelMethods extends DiscordBase {
if (!this.guildId) return []; if (!this.guildId) return [];
const states = await this.cache.voiceStates?.values(this.guildId); const states = await this.cache.voiceStates?.values(this.guildId);
if (!states?.length) return []; if (!states?.length) return [];
const filter = states.filter(state => state.channelId === this.id); return states.filter(state => state.channelId === this.id);
return filter;
} }
public async members(force?: boolean) { public async members(force?: boolean) {