Skip to content

Commit aab7108

Browse files
committed
Patch fix
1 parent 6d1647a commit aab7108

24 files changed

Lines changed: 17016 additions & 93 deletions

File tree

‎apps/docs/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fluxerjs/docs",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"private": true,
55
"license": "Apache-2.0",
66
"type": "module",

‎apps/docs/public/docs/latest/guides.json‎

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,32 @@
9898
},
9999
{
100100
"title": "client.channels.resolve() — get channel by ID",
101-
"description": "Resolve a channel by ID from cache or API. Use channel.isSendable() before sending. For sending when you only have an ID, prefer client.channels.send() which skips the fetch.",
102-
"code": "import { Client } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\n// Fetch channel (from API if not cached)\nconst channel = await client.channels.resolve(channelId);\nif (channel?.isSendable()) {\n await channel.send('Hello!');\n}\n// Or for webhooks: if (channel?.createWebhook) { ... }",
101+
"description": "Resolve a channel by ID from cache or API. Use channel.canSendMessage() or channel.isTextBased() before sending. For sending when you only have an ID, prefer client.channels.send() which skips the fetch.",
102+
"code": "import { Client } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\n// Fetch channel (from API if not cached)\nconst channel = await client.channels.resolve(channelId);\nif (channel?.canSendMessage()) {\n await channel.send('Hello!');\n}\n// Or for webhooks: if (channel?.createWebhook) { ... }",
103103
"language": "javascript"
104104
},
105105
{
106106
"title": "fetch message by id",
107107
"description": "Use channel.messages.fetch(messageId) when you have the channel. For IDs-only, fetch the channel first.",
108-
"code": "// When you have the channel\nconst message = await channel.messages.fetch(messageId);\nif (message) {\n await message.edit({ content: 'Updated!' });\n await message.react('👍');\n}\n\n// When you only have IDs (e.g. from sqlite)\nconst ch = await client.channels.resolve(channelId);\nconst msg = await ch?.messages?.fetch(messageId);\nif (msg) await msg.delete();\n\n// When channel is cached\nconst m = client.channels.get(channelId);\nif (m?.isSendable()) {\n const mes = await m.messages.fetch(messageId);\n if (mes) await mes.edit({ content: 'Edited!' });\n}\n\n// Refresh a stale message instance\nconst updated = await message.fetch();\nif (updated) console.log(updated.content);",
108+
"code": "// When you have the channel\nconst message = await channel.messages.fetch(messageId);\nif (message) {\n await message.edit({ content: 'Updated!' });\n await message.react('👍');\n}\n\n// When you only have IDs (e.g. from sqlite)\nconst ch = await client.channels.resolve(channelId);\nconst msg = await ch?.messages?.fetch(messageId);\nif (msg) await msg.delete();\n\n// When channel is cached\nconst m = client.channels.get(channelId);\nif (m?.canSendMessage()) {\n const mes = await m.messages.fetch(messageId);\n if (mes) await mes.edit({ content: 'Edited!' });\n}\n\n// Refresh a stale message instance\nconst updated = await message.fetch();\nif (updated) console.log(updated.content);",
109109
"language": "javascript"
110110
},
111111
{
112-
"title": "message.channel and message.guild",
113-
"description": "Access the channel or guild from a message. Resolved from cache; null if not cached (e.g. DM channel).",
114-
"code": "client.on(Events.MessageCreate, async (message) => {\n const channel = message.channel; // TextChannel or DMChannel | null\n const guild = message.guild; // Guild | null (null for DMs)\n if (message.channel?.isSendable()) {\n await message.channel.send('Same channel, different API');\n }\n});",
112+
"title": "message.channel and message.channel.send()",
113+
"description": "message.channel returns the channel (from cache); null if not cached. Messages only exist in text-based channels, so when non-null it always has send(). Use message.channel.send() for the same as message.send() but via the channel object.",
114+
"code": "client.on(Events.MessageCreate, async (message) => {\n const channel = message.channel; // TextChannel | DMChannel | GuildChannel | null\n const guild = message.guild; // Guild | null (null for DMs)\n if (channel) {\n await channel.send('Same channel, different API'); // or message.send()\n }\n});",
115+
"language": "javascript"
116+
},
117+
{
118+
"title": "channel.canSendMessage() — permission check",
119+
"description": "Before sending, use canSendMessage() to check if the bot has ViewChannel and SendMessages. For DMs always true; for guild channels uses guild.members.me permissions.",
120+
"code": "const channel = await client.channels.resolve(channelId);\nif (channel?.canSendMessage()) {\n await channel.send('Hello!');\n}",
115121
"language": "javascript"
116122
},
117123
{
118124
"title": "Typing indicator",
119125
"description": "Use channel.sendTyping() before a slow operation so users see \"Bot is typing...\". Lasts ~10 seconds.",
120-
"code": "const channel = message.channel ?? (await message.resolveChannel());\nif (channel?.isSendable?.()) {\n await channel.sendTyping();\n await slowOperation(); // e.g. fetch external API\n await message.reply('Done!');\n}",
126+
"code": "const channel = message.channel ?? (await message.resolveChannel());\nif (channel?.canSendMessage?.()) {\n await channel.sendTyping();\n await slowOperation(); // e.g. fetch external API\n await message.reply('Done!');\n}",
121127
"language": "javascript"
122128
},
123129
{
@@ -573,6 +579,30 @@
573579
}
574580
]
575581
},
582+
{
583+
"id": "wait-for-guilds",
584+
"slug": "wait-for-guilds",
585+
"title": "Wait for All Guilds",
586+
"description": "Delay the Ready event until all guilds have been received. Use when your bot needs the full guild cache before handling Ready.",
587+
"category": "events",
588+
"sections": [
589+
{
590+
"title": "Overview",
591+
"description": "By default, Ready fires as soon as the gateway sends the READY payload. Some guilds may be sent as unavailable stubs and arrive later via GUILD_CREATE. Enable waitForGuilds if your Ready handler needs every guild to be in client.guilds before proceeding."
592+
},
593+
{
594+
"title": "Usage",
595+
"description": "Pass waitForGuilds: true in ClientOptions. Ready will emit only after all guilds from READY (including those marked unavailable) have been received via GUILD_CREATE.",
596+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({\n waitForGuilds: true,\n});\n\nclient.on(Events.Ready, () => {\n // client.guilds now contains every guild — no stubs, all fully loaded\n console.log(`Bot is in ${client.guilds.size} guilds`);\n for (const [id, guild] of client.guilds) {\n console.log(`- ${guild.name} (${guild.channels.size} channels)`);\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
597+
"language": "javascript"
598+
},
599+
{
600+
"title": "When to use it",
601+
"description": "Use waitForGuilds when your bot iterates over all guilds in Ready (e.g. syncing state, broadcasting announcements, or building in-memory caches). Without it, client.guilds may be incomplete at Ready time.",
602+
"tip": "If you only need a few guilds by ID, prefer client.guilds.resolve(guildId) instead — no need to wait for all guilds."
603+
}
604+
]
605+
},
576606
{
577607
"id": "events",
578608
"slug": "events",
@@ -976,7 +1006,7 @@
9761006
{
9771007
"title": "Channel-specific permissions",
9781008
"description": "member.permissionsIn(channel) applies channel overwrites. Use it when checking if a user can send messages, read history, or connect to voice in a specific channel.",
979-
"code": "const channel = message.channel;\nif (channel?.isSendable?.()) {\n const perms = member.permissionsIn(channel);\n if (perms.has(PermissionFlags.SendMessages)) {\n await channel.send('You can send here!');\n }\n}",
1009+
"code": "const channel = message.channel;\nif (channel?.canSendMessage?.()) {\n const perms = member.permissionsIn(channel);\n if (perms.has(PermissionFlags.SendMessages)) {\n await channel.send('You can send here!');\n }\n}",
9801010
"language": "javascript"
9811011
},
9821012
{

0 commit comments

Comments
 (0)