mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 05:56:09 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { APIChannel } from 'discord-api-types/v10';
|
|
import { fakePromise } from '../../common';
|
|
import type { AllChannels } from '../../structures';
|
|
import channelFrom from '../../structures/channels';
|
|
import type { ReturnCache } from '../index';
|
|
import { GuildRelatedResource } from './default/guild-related';
|
|
|
|
export class Channels extends GuildRelatedResource {
|
|
namespace = 'channel';
|
|
|
|
parse(data: APIChannel, id: string, guild_id: string) {
|
|
const { permission_overwrites, ...rest } = super.parse(data, id, guild_id);
|
|
return rest;
|
|
}
|
|
|
|
override get(id: string): ReturnCache<AllChannels | undefined> {
|
|
return fakePromise(super.get(id)).then(rawChannel =>
|
|
rawChannel ? channelFrom(rawChannel, this.client) : undefined,
|
|
);
|
|
}
|
|
|
|
override bulk(ids: string[]): ReturnCache<ReturnType<typeof channelFrom>[]> {
|
|
return fakePromise(super.bulk(ids)).then(channels =>
|
|
channels.map(rawChannel => channelFrom(rawChannel, this.client)),
|
|
);
|
|
}
|
|
|
|
override values(guild: string): ReturnCache<ReturnType<typeof channelFrom>[]> {
|
|
return fakePromise(super.values(guild)).then(channels =>
|
|
channels.map(rawChannel => channelFrom(rawChannel, this.client)),
|
|
);
|
|
}
|
|
}
|