mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 12:36:08 +00:00

* feat: add support for new Discord application emojis features * feat: add support for new Discord application emojis features * feat: applications emojis routes * chore: switch typings provider * fix: unnecesary type * feat: magic bytes * chore: move api-types * chore: ? * fix: omg npm * chore: apply formatting * fix: for fast merge --------- Co-authored-by: Tony Supremacy <165050835+VanStk@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import type { APIBan, GatewayGuildBanModifyDispatchData } from '../../types';
|
|
import type { ReturnCache } from '../..';
|
|
import { fakePromise } from '../../common';
|
|
import { GuildBasedResource } from './default/guild-based';
|
|
import { type GuildBanStructure, Transformers } from '../../client/transformers';
|
|
export class Bans extends GuildBasedResource<any, GatewayGuildBanModifyDispatchData | APIBan> {
|
|
namespace = 'ban';
|
|
|
|
//@ts-expect-error
|
|
filter(data: APIBan, id: string, guild_id: string) {
|
|
return true;
|
|
}
|
|
|
|
override parse(data: any, key: string, guild_id: string) {
|
|
const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
|
|
return rest;
|
|
}
|
|
|
|
override get(id: string, guild: string): ReturnCache<GuildBanStructure | undefined> {
|
|
return fakePromise(super.get(id, guild)).then(rawBan =>
|
|
rawBan ? Transformers.GuildBan(this.client, rawBan, guild) : undefined,
|
|
);
|
|
}
|
|
|
|
raw(id: string, guild: string): ReturnCache<Omit<GatewayGuildBanModifyDispatchData | APIBan, 'user'> | undefined> {
|
|
return super.get(id, guild);
|
|
}
|
|
|
|
override bulk(ids: string[], guild: string): ReturnCache<GuildBanStructure[]> {
|
|
return fakePromise(super.bulk(ids, guild)).then(
|
|
bans =>
|
|
bans
|
|
.map(rawBan => {
|
|
return rawBan ? Transformers.GuildBan(this.client, rawBan, guild) : undefined;
|
|
})
|
|
.filter(Boolean) as GuildBanStructure[],
|
|
);
|
|
}
|
|
|
|
bulkRaw(ids: string[], guild: string): ReturnCache<Omit<GatewayGuildBanModifyDispatchData | APIBan, 'user'>[]> {
|
|
return super.bulk(ids, guild);
|
|
}
|
|
|
|
override values(guild: string): ReturnCache<GuildBanStructure[]> {
|
|
return fakePromise(super.values(guild)).then(
|
|
bans =>
|
|
bans
|
|
.map(rawBan => {
|
|
return rawBan ? Transformers.GuildBan(this.client, rawBan, guild) : undefined;
|
|
})
|
|
.filter(Boolean) as GuildBanStructure[],
|
|
);
|
|
}
|
|
|
|
valuesRaw(guild: string): ReturnCache<Omit<GatewayGuildBanModifyDispatchData | APIBan, 'user'>[]> {
|
|
return super.values(guild);
|
|
}
|
|
}
|