This commit is contained in:
NoLogicAlan committed 2026-05-05 18:32:51 +03:00
1 parent 034d64e830
commit 19820e7209
1 file changed
+15 -3
+15 -3
View File
@@ -237,14 +237,26 @@ export class Dashboard {
* @param {import("discord.js").Guild} guild * @param {import("discord.js").Guild} guild
*/ */
static convertServer(guild) { static convertServer(guild) {
// Defensively handle guild.channels — @fluxerjs/core may not always
// populate .cache (e.g. during recovery or for partial guild objects),
// or guild.channels itself may be a Map/Collection without a .cache
// wrapper. Fallback to guild.channels directly if .cache is absent.
const channelStore = guild.channels?.cache ?? guild.channels;
const channelIds = channelStore && typeof channelStore.keys === "function"
? [...channelStore.keys()]
: [];
const channelValues = channelStore && typeof channelStore.values === "function"
? [...channelStore.values()]
: [];
return { return {
name: guild.name, name: guild.name,
id: guild.id, id: guild.id,
icon: guild.iconURL() ?? null, icon: typeof guild.iconURL === "function" ? guild.iconURL() : null,
channelIds: [...guild.channels.cache.keys()], channelIds,
description: guild.description ?? null, description: guild.description ?? null,
ownerId: guild.ownerId, ownerId: guild.ownerId,
channels: [...guild.channels.cache.values()].map(Dashboard.convertChannel), channels: channelValues.map(Dashboard.convertChannel),
}; };
} }