Typeseedcordv0.13.0Internal
ContextMenuKindOf
The context-menu kind a handler serves, read off its event's commandTypecommandType discriminant. Reading the literal off the event rather than inferring the ContextMenuHandlerContextMenuHandler generic directly keeps the kind from widening to the whole union, the handler's conditional members make the generic inference imprecise.
type ContextMenuKindOf<
TCtor extends new (
...args: any[]
) => InteractionHandler<Repliables>
> =
InstanceType<TCtor> extends ContextMenuHandler<
infer Kind,
CacheType
>
? [Kind] extends [ApplicationCommandType.User | ApplicationCommandType.Message]
? HandlerEventType<TCtor> extends { commandType: infer K }
? Extract<K, ApplicationCommandType.User | ApplicationCommandType.Message>
: never
: never
: never;type ContextMenuKindOf<
TCtor extends new (
...args: any[]
) => InteractionHandler<Repliables>
> =
InstanceType<TCtor> extends ContextMenuHandler<
infer Kind,
CacheType
>
? [Kind] extends [ApplicationCommandType.User | ApplicationCommandType.Message]
? HandlerEventType<TCtor> extends { commandType: infer K }
? Extract<K, ApplicationCommandType.User | ApplicationCommandType.Message>
: never
: never
: never;TCtor
TCtor extends new (...args: any[]) => InteractionHandler<Repliables>TCtor extends new (...args: any[]) => InteractionHandler<Repliables>