|
1 | 1 | import { TFunction } from 'i18next'; |
2 | 2 | import { |
| 3 | + ApplicationIntegrationType, |
| 4 | + InteractionContextType, |
3 | 5 | RESTPostAPIApplicationCommandsJSONBody as ApplicationCommand, |
4 | 6 | RESTPostAPIApplicationGuildCommandsJSONBody as ApplicationGuildCommand, |
5 | 7 | type RESTPostAPIChatInputApplicationCommandsJSONBody, |
6 | | -} from 'discord-api-types/v10.js'; |
| 8 | +} from 'discord-api-types/v10'; |
7 | 9 | import { chatInputCommandMap, chatInputCommandNames } from './commands.js'; |
8 | 10 | import { messageContextMenuCommandMap, messageContextMenuCommands } from './message-context-menu-commands.js'; |
9 | 11 |
|
10 | | -const commonChatInputCommandOptions: Partial<RESTPostAPIChatInputApplicationCommandsJSONBody> = { |
11 | | - dm_permission: true, |
12 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Missing beta keys from types |
13 | | - // @ts-ignore |
14 | | - integration_types: [0, 1], |
15 | | - contexts: [0, 1, 2], |
| 12 | +const commonCommandOptions: Pick<RESTPostAPIChatInputApplicationCommandsJSONBody, 'integration_types' | 'contexts'> = { |
| 13 | + integration_types: [ApplicationIntegrationType.UserInstall, ApplicationIntegrationType.GuildInstall], |
| 14 | + contexts: [InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel], |
16 | 15 | }; |
17 | 16 |
|
18 | 17 | export const getApplicationCommands = (t: TFunction): (ApplicationGuildCommand & ApplicationCommand)[] => [ |
19 | 18 | ...chatInputCommandNames.map((commandName) => ({ |
20 | | - ...commonChatInputCommandOptions, |
| 19 | + ...commonCommandOptions, |
21 | 20 | ...chatInputCommandMap[commandName].getDefinition(t), |
22 | 21 | })), |
23 | | - ...messageContextMenuCommands.map((commandName) => messageContextMenuCommandMap[commandName].getDefinition(t)), |
| 22 | + ...messageContextMenuCommands.map((commandName) => ({ |
| 23 | + ...messageContextMenuCommandMap[commandName].getDefinition(t), |
| 24 | + ...commonCommandOptions, |
| 25 | + })), |
24 | 26 | ]; |
0 commit comments