mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat(MessageMethods#list): implements /channels/{channel.id}/messages for getting bulk messages (#297)
* feat(Formatter#generateOAuth2URL): addition of a new method for creating discord oauth2 links * feat(MessageMethods#list): implements /channels/{channel.id}/messages for getting bulk messages
This commit is contained in:
parent
3e14166247
commit
d6a305a371
@ -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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user