mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
a0a1554756
* fix: check new types idea * fix: type errors * fix: new style * fix: more cleanup * fix: more cleanup * fix: cleanup audit logs * fix: cleanup stickers * fix: cleanup integrations * fix: more cleanup * fix: organize into 1 place * fix: few errors * fix: some broken import fixes * fix: quite a lot of fixes across the board * fix: more fixes for broken imports * fix: more fixes for broken imports * fix: handler imports * fix: all remaining import errors * fix: more errors needing fixes * fix: clearing up transformers * fix: few moer types * fix: more cleanup of extra types * fix: fmt * fix: cleanup discordeno file * Nuke Base Types (#2102) * fix: cleanup snake stuff * convert camelCase to snake_case (#2103) * fix: add camelize * fix: finalize remaining errors * fix: imports in test Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Bot } from "../../bot.ts";
|
|
import { statusTypes } from "../../transformers/presence.ts";
|
|
import { DiscordGatewayPayload, DiscordGuildMembersChunk } from "../../types/discord.ts";
|
|
|
|
export async function handleGuildMembersChunk(bot: Bot, data: DiscordGatewayPayload) {
|
|
const payload = data.d as DiscordGuildMembersChunk;
|
|
|
|
const guildId = bot.transformers.snowflake(payload.guild_id);
|
|
|
|
if (payload.nonce && payload.chunk_index >= payload.chunk_count - 1) {
|
|
bot.cache.fetchAllMembersProcessingRequests.get(payload.nonce)?.(
|
|
`Member fetching complete. Nonce: ${payload.nonce}`,
|
|
);
|
|
}
|
|
|
|
return {
|
|
guildId,
|
|
members: payload.members.map((m) =>
|
|
bot.transformers.member(bot, m, guildId, bot.transformers.snowflake(m.user.id))
|
|
),
|
|
chunkIndex: payload.chunk_index,
|
|
chunkCount: payload.chunk_count,
|
|
notFound: payload.not_found?.map((id) => bot.transformers.snowflake(id)),
|
|
presences: payload.presences?.map((presence) => ({
|
|
user: bot.transformers.user(bot, presence.user),
|
|
guildId,
|
|
status: statusTypes[presence.status],
|
|
activities: presence.activities.map((activity) => bot.transformers.activity(bot, activity)),
|
|
clientStatus: {
|
|
desktop: presence.client_status.desktop,
|
|
mobile: presence.client_status.mobile,
|
|
web: presence.client_status.web,
|
|
},
|
|
})),
|
|
nonce: payload.nonce,
|
|
};
|
|
}
|