11import type {
2- CacheType ,
32 MessageContextMenuCommandInteraction ,
43 PermissionsString ,
54 UserContextMenuCommandInteraction
65} from 'discord.js'
76
8- export type ContextMenuCallback = (
9- interaction :
10- | MessageContextMenuCommandInteraction < CacheType >
11- | UserContextMenuCommandInteraction < CacheType >
7+ export type ContextMenuCallback < Type extends 'message' | 'user' > = (
8+ interaction : Type extends 'message'
9+ ? MessageContextMenuCommandInteraction
10+ : UserContextMenuCommandInteraction
1211) => void
1312
1413export interface ContextMenuOptions {
@@ -18,17 +17,17 @@ export interface ContextMenuOptions {
1817 preconditions ?: string [ ]
1918}
2019
21- export type DefineContextMenu = (
22- callback : ContextMenuCallback
20+ export type DefineContextMenu = < Type extends 'message' | 'user' > (
21+ callback : ContextMenuCallback < Type >
2322) => HarmonixContextMenu
24- export type DefineContextMenuWithOptions = (
23+ export type DefineContextMenuWithOptions = < Type extends 'message' | 'user' > (
2524 options : ContextMenuOptions ,
26- callback : ContextMenuCallback
25+ callback : ContextMenuCallback < Type >
2726) => HarmonixContextMenu
2827
2928export type HarmonixContextMenuInput = string | HarmonixContextMenu
3029
3130export interface HarmonixContextMenu {
3231 options : ContextMenuOptions
33- callback : ContextMenuCallback
32+ callback : ContextMenuCallback < 'message' | 'user' >
3433}
0 commit comments