You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ℹ️ This goes hand-in-hand with #6567, and as such, the linked PR must be solved before this one.
❓ The problem
Currently, the way we handle channels in the library is overwhelmingly complex, for example, just to create the channel class, we need a lot of checks:
On a large scale, those checks cause the shard ready quite slower.
✅ The solution
We can make a single class following whichever design we take with the aforementioned PR, change the extended classes to interfaces, and use #6957 to cast Channel to those interfaces.
No need for inheritance trees, middle-ground shared classes (BaseGuildTextChannel, BaseGuildVoiceChannel, and GuildChannel) and future ones that might arise in the future.
(?) Less memory usage due to channel managers storing only 1 class as opposed to using a lot of different classes with different shapes (https://mathiasbynens.be/notes/shapes-ics).
⬇️ Downsides
A single class for everything means a very complex class.
How do we manage message caches? Should we remove them? Issue soon!
The text was updated successfully, but these errors were encountered:
❓ The problem
Currently, the way we handle channels in the library is overwhelmingly complex, for example, just to create the channel class, we need a lot of checks:
discord.js/packages/discord.js/src/structures/Channel.js
Lines 192 to 251 in c10afea
(And let's not mention it's also a class that requires quite a workaround to work, as seen below):
discord.js/packages/discord.js/src/structures/Channel.js
Line 31 in c10afea
Furthermore, changing channel types is not easy:
discord.js/packages/discord.js/src/client/actions/ChannelUpdate.js
Lines 14 to 19 in c10afea
On a large scale, those checks cause the shard ready quite slower.
✅ The solution
We can make a single class following whichever design we take with the aforementioned PR, change the extended classes to interfaces, and use #6957 to cast Channel to those interfaces.
Some stuff such as the line below:
discord.js/packages/discord.js/src/structures/GuildChannel.js
Lines 27 to 31 in c10afea
Would just be a getter, following the design from the
Message
class:discord.js/packages/discord.js/src/structures/Message.js
Lines 37 to 41 in c10afea
discord.js/packages/discord.js/src/structures/Message.js
Lines 397 to 399 in c10afea
⬆️ Upsides
BaseGuildTextChannel
,BaseGuildVoiceChannel
, andGuildChannel
) and future ones that might arise in the future.⬇️ Downsides
The text was updated successfully, but these errors were encountered: