Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MARCROCK22 committed Nov 17, 2024
2 parents 5a76f7c + d6a305a commit fd7c116
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/common/shorters/messages.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { resolveFiles } from '../../builders';
import { MessagesMethods } from '../../structures';
import type {
RESTGetAPIChannelMessagesQuery,
RESTPatchAPIChannelMessageJSONBody,
RESTPostAPIChannelMessageJSONBody,
RESTPostAPIChannelMessagesThreadsJSONBody,
} from '../../types';

import type { ValidAnswerId } from '../../api/Routes/channels';
import { Transformers } from '../../client/transformers';
import { Transformers } from '../../client';
import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
import { BaseShorter } from './base';

Expand Down Expand Up @@ -111,4 +112,11 @@ export class MessageShorter extends BaseShorter {
.get()
.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)));
}
}
7 changes: 4 additions & 3 deletions src/structures/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
type ThreadChannelStructure,
Transformers,
type VoiceChannelStructure,
} from '../client/transformers';
} from '../client';
import type { UsingClient } from '../commands';
import type {
EmojiResolvable,
Expand Down Expand Up @@ -45,6 +45,7 @@ import {
ChannelType,
type RESTAPIAttachment,
type RESTGetAPIChannelMessageReactionUsersQuery,
type RESTGetAPIChannelMessagesQuery,
type RESTPatchAPIChannelJSONBody,
type RESTPatchAPIGuildChannelPositionsJSONBody,
type RESTPostAPIChannelWebhookJSONBody,
Expand Down Expand Up @@ -253,6 +254,7 @@ export class MessagesMethods extends DiscordBase {
delete: (messageId: string, reason?: string) => ctx.client.messages.delete(messageId, ctx.channelId, reason),
fetch: (messageId: string) => ctx.client.messages.fetch(messageId, ctx.channelId),
purge: (messages: string[], reason?: string) => ctx.client.messages.purge(messages, ctx.channelId, reason),
list: (fetchOptions: RESTGetAPIChannelMessagesQuery) => ctx.client.messages.list(ctx.channelId, fetchOptions),
};
}

Expand Down Expand Up @@ -406,8 +408,7 @@ export class VoiceChannelMethods extends DiscordBase {
if (!this.guildId) return [];
const states = await this.cache.voiceStates?.values(this.guildId);
if (!states?.length) return [];
const filter = states.filter(state => state.channelId === this.id);
return filter;
return states.filter(state => state.channelId === this.id);
}

public async members(force?: boolean) {
Expand Down

0 comments on commit fd7c116

Please sign in to comment.