-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
channelFactory typings #97
Comments
A better way of typing the channelFactory: type Channel = GuildTextChannel | DmChannel | GroupDmChannel | ...
function channelFactory<T extends ChannelType = ChannelType>(): Extract<Channel, { type: T }> { ... } |
I see you assigned this to me, can you clarify what needs to be changed? I might have misunderstood when I made my original comment. @thewilloftheshadow |
Sure @apteryxxyz (I didn't assign it based on your comment fyi, just distributing issues) Right now the channelFactory is a way to abstract out passing in an unknown channel type and get back the proper class, but its always typed as the BaseChannel making it not very useful for the end user (e.g. interaction.channel is always a BaseChannel) There's either two ways of fixing this from what I see, but open to other ideas:
|
I got you, I played around before with creating a single channel class though it's a real mess full of type conditional, I'll share it on Discord when I get home. |
Right now the channelFactory typings aren't great, you get a vague "This is a channel of some sort" bc it extends the BaseChannel, which isn't ideal.
Need to either find a better way to create channel classes or find a way to type the channelFactory's result
The text was updated successfully, but these errors were encountered: