seyfert/src/cache/resources/threads.ts
Marcos Susaña 026805bcb2
Seyfert 2.0 (#208)
* feat: permissible handlers

Co-authored-by: MARCROCK22 <MARCROCK22@users.noreply.github.com>

* feat: init handle command

* feat: unifique interaction/message (not full tested)

* fix: await

* fix: components handler

* fix: console.log

* feat: init transformers

* fix: xd

* fix: check

* chore: apply formatting

* chore: frozen-lockfile

* fix: use pnpm v9

* fix: use pnpm v9

* fix: guildCreate emits when bot has more than 1 shard

* feat: update cache adapter

* fix: types

* fix: limitedAdapter messages and bans support

* fix: yes

* feat: transformers (huge update)

* fix: pnpm

* feat: transformers & handleCommand methods

* feat(resolveCommandFromContent): for handle content of getCommandFrom Content and argsContent

* fix: use raw

* fix: consistency

* fix: return await

* chore: export transformers

* fix: socram code

* fix: handleCommand & types

* fix: events

---------

Co-authored-by: MARCROCK22 <MARCROCK22@users.noreply.github.com>
Co-authored-by: MARCROCK22 <marcos22dev@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: douglas546899 <douglas546899@gmail.com>
Co-authored-by: Aarón Rafael <69669283+Chewawi@users.noreply.github.com>
Co-authored-by: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com>
2024-06-20 20:59:55 -04:00

33 lines
1.2 KiB
TypeScript

import type { APIThreadChannel } from 'discord-api-types/v10';
import type { ReturnCache } from '../..';
import { fakePromise } from '../../common';
import { GuildRelatedResource } from './default/guild-related';
import { type ThreadChannelStructure, Transformers } from '../../client/transformers';
export class Threads extends GuildRelatedResource {
namespace = 'thread';
//@ts-expect-error
filter(data: APIThreadChannel, id: string, guild_id?: string) {
return true;
}
override get(id: string): ReturnCache<ThreadChannelStructure | undefined> {
return fakePromise(super.get(id)).then(rawThread =>
rawThread ? Transformers.ThreadChannel(this.client, rawThread) : undefined,
);
}
override bulk(ids: string[]): ReturnCache<ThreadChannelStructure[]> {
return fakePromise(super.bulk(ids) as APIThreadChannel[]).then(threads =>
threads.map(rawThread => Transformers.ThreadChannel(this.client, rawThread)),
);
}
override values(guild: string): ReturnCache<ThreadChannelStructure[]> {
return fakePromise(super.values(guild) as APIThreadChannel[]).then(threads =>
threads.map(rawThread => Transformers.ThreadChannel(this.client, rawThread)),
);
}
}