-
Notifications
You must be signed in to change notification settings - Fork 4
fix: register thread collection #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes update import statements in the database manager service to directly import certain entities and interfaces, including a new Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant DatabaseManager
participant GuildDB
App->>DatabaseManager: setupModels()
DatabaseManager->>GuildDB: Register model "Thread" (IThread, threadSchema)
Note right of GuildDB: Thread model is now available
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/services/databaseManager.ts (2)
2-5
: Preferimport type
for type-only symbols
Snowflake
,Connection
, and everyI*
interface are erased at runtime. Importing them as regular values pulls the corresponding modules into the compiled JS bundle (and can even trigger circular-dependency warnings in ESM loaders), whileimport type
keeps the emit lean:-import { Snowflake } from 'discord.js'; -import mongoose, { Connection } from 'mongoose'; -import { IChannel, IGuildMember, IHeatMap, IMemberActivity, IRawInfo, IRole, IThread } from '../interfaces'; +import type { Snowflake } from 'discord.js'; +import mongoose from 'mongoose'; +import type { Connection } from 'mongoose'; +import type { + IChannel, + IGuildMember, + IHeatMap, + IMemberActivity, + IRawInfo, + IRole, + IThread, +} from '../interfaces';No behaviour change, but cleaner byte-code and avoids accidental value-namespace collisions.
13-15
: Schema import order nit
threadSchema
breaks the existing alphabetical / logical grouping (rawInfoSchema
,roleSchema
, …). Re-ordering keeps diffs small and improves scan-ability for future contributors.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/services/databaseManager.ts
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/services/databaseManager.ts (2)
src/interfaces/Thread.interface.ts (1)
IThread
(13-30)src/models/schemas/index.ts (1)
threadSchema
(29-29)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: ci / lint / Lint
🔇 Additional comments (1)
src/services/databaseManager.ts (1)
54-55
: 👍 Thread model successfully registeredRegistering
Thread
inside the guild branch is consistent with the other per-guild collections. Nothing else to flag here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/models/schemas/Thread.schema.ts (1)
58-61
: Consider using a more specific schema type for themember
field.Using
Schema.Types.Mixed
provides flexibility but sacrifices type safety and validation. If the structure of the member data is known, consider defining a proper schema for it.src/interfaces/Thread.interface.ts (3)
13-19
: Consider defining a more specific type for themember
field.The
member
field is typed asany
, which reduces type safety. If the structure is known, consider defining a proper interface for it. This could be a DiscordGuildMember
type or a custom interface.Based on Discord API, this could potentially be:
- member?: any; + member?: GuildMember | null;Or define a custom interface if you need a subset of guild member properties.
64-64
: Consider using a type alias forThreadUpdateEvent
.Since
ThreadUpdateEvent
doesn't add any properties toBaseThread
, a type alias would be more concise.-export interface ThreadUpdateEvent extends BaseThread {} +export type ThreadUpdateEvent = BaseThread;
92-92
: Consider using a type alias forIThread
.Similar to
ThreadUpdateEvent
, sinceIThread
doesn't add properties toBaseThread
, a type alias would be cleaner.-export interface IThread extends BaseThread {} +export type IThread = BaseThread;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (3)
package.json
(1 hunks)src/interfaces/Thread.interface.ts
(4 hunks)src/models/schemas/Thread.schema.ts
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- package.json
🔇 Additional comments (4)
src/models/schemas/Thread.schema.ts (3)
66-78
: LGTM!The
defaultReactionSchema
is well-structured with appropriate nullable fields for emoji data.
89-90
: Verify if empty forum tag names should be allowed.The
minlength: 0
constraint allows empty strings for forum tag names. Please confirm if this is intentional, as empty tag names might not be meaningful in the UI.
181-217
: LGTM! New forum channel fields are well-implemented.The new fields properly support Discord's forum channel features with appropriate validations:
- Enum constraints for archive duration, sort order, and forum layout
- Min/max constraints for rate limits
- Proper schema references for complex types
src/interfaces/Thread.interface.ts (1)
36-36
:✅ Verification successful
Verify thread type enum values match Discord API.
Please confirm that the thread type values (10, 11, 12) correspond to the current Discord API channel types for threads.
🌐 Web query:
What are the Discord API channel type values for threads (GUILD_PUBLIC_THREAD, GUILD_PRIVATE_THREAD, GUILD_NEWS_THREAD)?
💡 Result:
The Discord API assigns the following channel type values for thread channels:
- GUILD_PUBLIC_THREAD: 11
- GUILD_PRIVATE_THREAD: 12
- GUILD_NEWS_THREAD: 10
These types correspond to temporary sub-channels created within existing guild text or announcement channels, used to organize conversations. Specifically:
GUILD_PUBLIC_THREAD
(11): A public thread within a guild text channel, visible to anyone who can view the parent channel.GUILD_PRIVATE_THREAD
(12): A private thread within a guild text channel, only accessible to users who are invited or have the appropriate permission.GUILD_NEWS_THREAD
(10): A thread created within a guild announcement (news) channel[7][9][10].Citations:
- 1: https://discord.com/developers/docs/resources/channel
- 2: https://discord.com/developers/docs/topics/threads
- 3: https://discord-api-types.dev/api/discord-api-types-v10/enum/ChannelType
- 4: https://discord-api-types.dev/api/discord-api-types-v10/interface/APIThreadChannel
- 5: https://next.discordjs.guide/guide/topics/threads
- 6: https://umod.org/community/discord/54333-error-while-trying-create-thread-in-forum-discordextensions
- 7: https://docs.hikari-py.dev/en/latest/reference/hikari/channels/
- 8: https://discord.js.org/docs/packages/discord-api-types/main/APIThreadChannel:Interface
- 9: https://github.com/discordjs/discord-api-types/blob/main/deno/payloads/v9/channel.ts
- 10: https://ci.dv8tion.net/job/JDA5/javadoc/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html
Thread type enum values align with Discord API
Confirmed that the values 10, 11, and 12 map to
GUILD_NEWS_THREAD
,GUILD_PUBLIC_THREAD
, andGUILD_PRIVATE_THREAD
respectively as per the official Discord API. No changes needed.
Summary by CodeRabbit