custom filter of Channels with their according Type
Hey so i would like a function similar to this:
that should return
PrivateThreadChannel| PublicThreadChannel
But it doesnt seem to work at all, i also tried with single types and its only working for single objs![](https://utfs.io/f/fb7f447d-1b42-4ea9-82d1-53ca5c6f80f6-1nq2cb.png)
17 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
djs 14.7.1
node v18.3.0
i really need test environment
should i create a sandbox ?
I have an idea
@_kkumar use generics
use what
i tried... but its doesnt really solve any problem
at least from what i thought...
so how would you get the correct typeguard from the ChannelType enum ?
i do understand but it wouldnt work for a dynamic channeltype and is the same as casting it pretty muhc
![](https://utfs.io/f/2c7cf629-f003-45b8-adb8-13805a042f67-1nq2cb.png)
that actually should give an error, but it doesnt 🤔 same as type casting,
yeah i know, so it really isnt a solution to my problem 🔝
mhm i dont understand how to use a generic here, you have an example
passing the channeltype as generic ? ChannelType is an enum tho...
i dont provide a type, i provide the ChannelType enum
i cant understand, i m sorry. Can you use the variable name ?
I use an array of enums through which the channel array should return the according type
It does if you do it for a single object, in my example you can call single.ownerId
if you do the same with the array it still returns GuildBasedChannel instead of PublicThreadChannel
--
Furthermore i want to provide an array of enums so the enums are dynamic => i cant cast them...
can you write me an example?
...
![](https://utfs.io/f/5d94cc19-626a-4bfa-ae51-2a63368d577a-1nq2cb.png)
i am probably far off from what you want to explain me, sorry!
imo best way even if overwriting
![](https://utfs.io/f/a311e9a5-9c32-4cde-b4c4-6a5866585d63-1nq2cb.png)
well yes but
ah that too yeah
you cant really do it so it gives type you want to put in
hm wait
so basically
![](https://utfs.io/f/19a84a83-14bb-4773-841d-bb68eba2212a-1nq2cb.png)
![](https://utfs.io/f/c4165663-6513-4b9e-a5eb-bc9bd80046e8-1nq2cb.png)