File tree 10 files changed +258
-262
lines changed
10 files changed +258
-262
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const isEventSource = (p: string) =>
36
36
p . replaceAll ( '\\' , '/' ) . includes ( 'src/app/events' ) ;
37
37
38
38
export async function bootstrapDevelopmentServer ( configPath ?: string ) {
39
+ process . env . COMMANDKIT_BOOTSTRAP_MODE = 'development' ;
39
40
const start = performance . now ( ) ;
40
41
const cwd = configPath || process . cwd ( ) ;
41
42
const configPaths = getPossibleConfigPaths ( cwd ) ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { isCompilerPlugin } from '../plugins';
8
8
import { createSpinner } from './utils' ;
9
9
10
10
export async function bootstrapProductionServer ( configPath ?: string ) {
11
+ process . env . COMMANDKIT_BOOTSTRAP_MODE = 'production' ;
11
12
const cwd = configPath || process . cwd ( ) ;
12
13
const config = await loadConfigFile ( cwd ) ;
13
14
const mainFile = join ( config . distDir , 'index.js' ) ;
@@ -22,6 +23,7 @@ export async function bootstrapProductionServer(configPath?: string) {
22
23
}
23
24
24
25
export async function createProductionBuild ( configPath ?: string ) {
26
+ process . env . COMMANDKIT_BOOTSTRAP_MODE = 'production' ;
25
27
const cwd = configPath || process . cwd ( ) ;
26
28
const config = await loadConfigFile ( cwd ) ;
27
29
Original file line number Diff line number Diff line change 1
1
export const COMMANDKIT_CACHE_TAG = Symbol ( 'kCommandKitCacheTag' ) ;
2
2
3
- export const COMMANDKIT_IS_DEV = ! ! process . env . COMMANDKIT_IS_DEV ;
3
+ export const COMMANDKIT_IS_DEV = process . env . COMMANDKIT_IS_DEV === 'true' ;
4
4
5
5
export const COMMANDKIT_IS_TEST = process . env . COMMANDKIT_IS_TEST === 'true' ;
6
6
7
+ export const COMMANDKIT_BOOTSTRAP_MODE = ( process . env
8
+ . COMMANDKIT_BOOTSTRAP_MODE || 'development' ) as 'development' | 'production' ;
9
+
7
10
/**
8
11
* Types of Hot Module Replacement events
9
12
*/
Original file line number Diff line number Diff line change
1
+ import { Locale } from 'discord.js' ;
2
+
3
+ export const DISCORD_LOCALES = new Set (
4
+ Object . values ( Locale ) . filter ( ( locale ) => ! / ^ \d + / . test ( locale ) ) ,
5
+ ) ;
6
+
7
+ export const COMMAND_METADATA_KEY = '$command' ;
Original file line number Diff line number Diff line change
1
+ import type { Locale } from 'discord.js' ;
2
+ import type { CommandLocalizationContext } from './i18n' ;
3
+ import { useEnvironment } from 'commandkit' ;
4
+
5
+ /**
6
+ * Gets the localization context.
7
+ * @param locale The locale to use. Defaults to the detected locale or the default locale.
8
+ */
9
+ export function locale ( locale ?: Locale ) : CommandLocalizationContext {
10
+ const env = useEnvironment ( ) ;
11
+ const context = env . context ;
12
+
13
+ if ( ! context ) {
14
+ throw new Error ( 'No localization context found' ) ;
15
+ }
16
+
17
+ return context . locale ( locale ) ;
18
+ }
You can’t perform that action at this time.
0 commit comments