create-commandkit 1.2.0-next-beta.20240203230621 → 1.2.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -0
- package/README.md +2 -2
- package/dist/functions/copyTemplates.d.ts +5 -0
- package/dist/functions/copyTemplates.js +47 -0
- package/dist/functions/installDeps.d.ts +10 -0
- package/dist/functions/installDeps.js +49 -0
- package/dist/functions/setup.d.ts +10 -0
- package/dist/functions/setup.js +68 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +105 -5
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +49 -0
- package/package.json +16 -17
- package/templates/JavaScript/{cjs/README.md → README.md} +7 -1
- package/templates/JavaScript/commandkit-env.d.ts +1 -0
- package/templates/JavaScript/commandkit.config.mjs +3 -0
- package/templates/JavaScript/jsconfig.json +30 -0
- package/templates/JavaScript/src/app/commands/ping.js +27 -0
- package/templates/JavaScript/src/app/events/clientReady/log.js +10 -0
- package/templates/JavaScript/src/app.js +7 -0
- package/templates/TypeScript/{cjs/README.md → README.md} +7 -1
- package/templates/TypeScript/commandkit-env.d.ts +1 -0
- package/templates/TypeScript/commandkit.config.ts +3 -0
- package/templates/TypeScript/src/app/commands/ping.ts +20 -0
- package/templates/TypeScript/src/app/events/clientReady/log.ts +8 -0
- package/templates/TypeScript/src/app.ts +7 -0
- package/templates/TypeScript/tsconfig.json +29 -0
- package/templates/JavaScript/cjs/commandkit.cjs +0 -6
- package/templates/JavaScript/cjs/src/commands/General/ping.js +0 -19
- package/templates/JavaScript/cjs/src/events/ready/ready.js +0 -4
- package/templates/JavaScript/cjs/src/index.js +0 -22
- package/templates/JavaScript/esm/README.md +0 -10
- package/templates/JavaScript/esm/commandkit.mjs +0 -6
- package/templates/JavaScript/esm/src/commands/General/ping.js +0 -17
- package/templates/JavaScript/esm/src/events/ready/ready.js +0 -4
- package/templates/JavaScript/esm/src/index.js +0 -26
- package/templates/TypeScript/cjs/commandkit.cjs +0 -6
- package/templates/TypeScript/cjs/src/commands/General/ping.ts +0 -18
- package/templates/TypeScript/cjs/src/events/ready/ready.ts +0 -5
- package/templates/TypeScript/cjs/src/index.ts +0 -22
- package/templates/TypeScript/cjs/tsconfig.json +0 -20
- package/templates/TypeScript/esm/README.md +0 -10
- package/templates/TypeScript/esm/commandkit.mjs +0 -6
- package/templates/TypeScript/esm/src/commands/General/ping.ts +0 -18
- package/templates/TypeScript/esm/src/events/ready/ready.ts +0 -5
- package/templates/TypeScript/esm/src/index.ts +0 -26
- package/templates/TypeScript/esm/tsconfig.json +0 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright 2025 Avraj Sahota
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/underctrl-io/commandkit/
|
|
2
|
+
<img src="https://raw.githubusercontent.com/underctrl-io/commandkit/main/apps/website/static/img/ckit_logo.svg" width="60%" />
|
|
3
3
|
<br />
|
|
4
4
|
<a href="https://ctrl.lol/discord"><img src="https://img.shields.io/discord/1055188344188973066?color=5865F2&logo=discord&logoColor=white" alt="support server" /></a>
|
|
5
5
|
<a href="https://www.npmjs.com/package/create-commandkit"><img src="https://img.shields.io/npm/v/create-commandkit?maxAge=3600" alt="npm version" /></a>
|
|
@@ -17,7 +17,7 @@ create-commandkit is a CLI utility to quickly instantiate a Discord bot with Com
|
|
|
17
17
|
|
|
18
18
|
## Documentation
|
|
19
19
|
|
|
20
|
-
You can find the full documentation [here](https://commandkit.
|
|
20
|
+
You can find the full documentation [here](https://commandkit.dev).
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const templates = {
|
|
4
|
+
js: path.join(import.meta.dirname, '..', '..', 'templates', 'JavaScript'),
|
|
5
|
+
ts: path.join(import.meta.dirname, '..', '..', 'templates', 'TypeScript'),
|
|
6
|
+
};
|
|
7
|
+
const gitignore = `
|
|
8
|
+
# dependencies
|
|
9
|
+
node_modules
|
|
10
|
+
|
|
11
|
+
# build output
|
|
12
|
+
build
|
|
13
|
+
out
|
|
14
|
+
dist
|
|
15
|
+
|
|
16
|
+
# commandkit
|
|
17
|
+
.commandkit
|
|
18
|
+
dist
|
|
19
|
+
compiled-commandkit.config.mjs
|
|
20
|
+
|
|
21
|
+
# env
|
|
22
|
+
**/*.env*
|
|
23
|
+
!**/*.env.example*
|
|
24
|
+
|
|
25
|
+
# logging
|
|
26
|
+
logs
|
|
27
|
+
*.log
|
|
28
|
+
npm-debug.log*
|
|
29
|
+
yarn-debug.log*
|
|
30
|
+
yarn-error.log*
|
|
31
|
+
lerna-debug.log*
|
|
32
|
+
.pnpm-debug.log*
|
|
33
|
+
|
|
34
|
+
# yarn v2+
|
|
35
|
+
.yarn/cache
|
|
36
|
+
.yarn/unplugged
|
|
37
|
+
.yarn/build-state.yml
|
|
38
|
+
.yarn/install-state.gz
|
|
39
|
+
.pnp.*
|
|
40
|
+
|
|
41
|
+
# other
|
|
42
|
+
**/*.DS_Store
|
|
43
|
+
`;
|
|
44
|
+
export async function copyTemplates({ dir, lang, }) {
|
|
45
|
+
await fs.copy(templates[lang], dir);
|
|
46
|
+
await fs.writeFile(path.join(dir, '.gitignore'), gitignore);
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IOType } from 'node:child_process';
|
|
2
|
+
import type { Language, PackageManager } from '../types';
|
|
3
|
+
interface InstallDepsProps {
|
|
4
|
+
manager: PackageManager;
|
|
5
|
+
dir: string;
|
|
6
|
+
lang: Language;
|
|
7
|
+
stdio: IOType;
|
|
8
|
+
}
|
|
9
|
+
export declare function installDeps({ manager, dir, lang, stdio, }: InstallDepsProps): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { getCommandKitVersion } from '../utils.js';
|
|
4
|
+
const getBaseDependencies = () => [
|
|
5
|
+
`commandkit${getCommandKitVersion()}`,
|
|
6
|
+
'discord.js',
|
|
7
|
+
];
|
|
8
|
+
const getDependencies = () => ({
|
|
9
|
+
js: {
|
|
10
|
+
dependencies: getBaseDependencies(),
|
|
11
|
+
devDependencies: ['@types/node', 'typescript', 'prettier'],
|
|
12
|
+
},
|
|
13
|
+
ts: {
|
|
14
|
+
dependencies: getBaseDependencies(),
|
|
15
|
+
devDependencies: ['@types/node', 'typescript', 'prettier'],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
function getInstallCommand(manager, deps, dev = false) {
|
|
19
|
+
switch (manager) {
|
|
20
|
+
case 'npm':
|
|
21
|
+
case 'pnpm':
|
|
22
|
+
case 'yarn':
|
|
23
|
+
case 'bun':
|
|
24
|
+
return `${manager} add ${dev ? '-D' : ''} ${deps.join(' ')}`;
|
|
25
|
+
case 'deno':
|
|
26
|
+
return `deno add ${dev ? '--dev' : ''} ${deps.map((d) => `npm:${d}`).join(' ')}`;
|
|
27
|
+
default:
|
|
28
|
+
return manager;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function installDeps({ manager, dir, lang, stdio = 'inherit', }) {
|
|
32
|
+
const spinner = ora('Installing dependencies...').start();
|
|
33
|
+
try {
|
|
34
|
+
const dependencies = getDependencies();
|
|
35
|
+
if (dependencies[lang].dependencies.length) {
|
|
36
|
+
const depsCommand = getInstallCommand(manager, dependencies[lang].dependencies);
|
|
37
|
+
execSync(depsCommand, { cwd: dir, stdio });
|
|
38
|
+
}
|
|
39
|
+
if (dependencies[lang].devDependencies.length) {
|
|
40
|
+
const devDepsCommand = getInstallCommand(manager, dependencies[lang].devDependencies, true);
|
|
41
|
+
execSync(devDepsCommand, { cwd: dir, stdio });
|
|
42
|
+
}
|
|
43
|
+
spinner.succeed('Dependencies installed successfully!');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
spinner.fail('Failed to install dependencies');
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IOType } from 'child_process';
|
|
2
|
+
import type { PackageManager } from '../types';
|
|
3
|
+
interface SetupProps {
|
|
4
|
+
manager: PackageManager;
|
|
5
|
+
token: string;
|
|
6
|
+
dir: string;
|
|
7
|
+
stdio?: IOType;
|
|
8
|
+
}
|
|
9
|
+
export declare function setup({ manager, token, dir, stdio, }: SetupProps): Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { commands } from '../utils.js';
|
|
5
|
+
export async function setup({ manager, token, dir, stdio = 'pipe', }) {
|
|
6
|
+
await fs.emptyDir(dir);
|
|
7
|
+
if (manager === 'yarn') {
|
|
8
|
+
execSync(commands.init.yarn, { cwd: dir, stdio });
|
|
9
|
+
}
|
|
10
|
+
if (manager === 'deno') {
|
|
11
|
+
const denoJsonPath = path.join(dir, 'deno.json');
|
|
12
|
+
const denoJson = {
|
|
13
|
+
compilerOptions: {
|
|
14
|
+
jsx: 'react-jsx',
|
|
15
|
+
jsxImportSource: 'commandkit',
|
|
16
|
+
},
|
|
17
|
+
nodeModulesDir: 'auto',
|
|
18
|
+
lock: true,
|
|
19
|
+
lint: {
|
|
20
|
+
include: ['src/'],
|
|
21
|
+
exclude: ['node_modules/', 'dist/', '.commandkit/'],
|
|
22
|
+
},
|
|
23
|
+
fmt: {
|
|
24
|
+
useTabs: false,
|
|
25
|
+
lineWidth: 120,
|
|
26
|
+
indentWidth: 2,
|
|
27
|
+
endOfLine: 'lf',
|
|
28
|
+
semiColons: true,
|
|
29
|
+
singleQuote: true,
|
|
30
|
+
include: ['src/'],
|
|
31
|
+
exclude: ['node_modules/', 'dist/', '.commandkit/'],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
await fs.writeJSON(denoJsonPath, denoJson, { spaces: 2, EOL: '\n' });
|
|
35
|
+
}
|
|
36
|
+
const prettierrc = path.join(dir, '.prettierrc');
|
|
37
|
+
const prettierConfig = {
|
|
38
|
+
printWidth: 120,
|
|
39
|
+
tabWidth: 2,
|
|
40
|
+
useTabs: false,
|
|
41
|
+
semi: true,
|
|
42
|
+
endOfLine: 'lf',
|
|
43
|
+
singleQuote: true,
|
|
44
|
+
trailingComma: 'all',
|
|
45
|
+
arrowParens: 'always',
|
|
46
|
+
};
|
|
47
|
+
await fs.writeJSON(prettierrc, prettierConfig, { spaces: 2, EOL: '\n' });
|
|
48
|
+
const packageJsonPath = path.join(dir, 'package.json');
|
|
49
|
+
const packageJson = {
|
|
50
|
+
name: dir.replaceAll('\\', '/').split('/').pop()?.toLowerCase() ||
|
|
51
|
+
'commandkit-project',
|
|
52
|
+
description: 'A CommandKit project',
|
|
53
|
+
version: '0.1.0',
|
|
54
|
+
type: 'module',
|
|
55
|
+
private: true,
|
|
56
|
+
main: 'dist/index.js',
|
|
57
|
+
scripts: {
|
|
58
|
+
dev: 'commandkit dev',
|
|
59
|
+
build: 'commandkit build',
|
|
60
|
+
start: 'commandkit start',
|
|
61
|
+
format: 'prettier --write "src/**/*.{js,ts}"',
|
|
62
|
+
},
|
|
63
|
+
devDependencies: {},
|
|
64
|
+
dependencies: {},
|
|
65
|
+
};
|
|
66
|
+
await fs.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
|
|
67
|
+
await fs.writeFile(`${dir}/.env`, `DISCORD_TOKEN="${token || ''}"`);
|
|
68
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
console.clear();
|
|
3
|
+
import { confirm, intro, outro, password, select, text } from '@clack/prompts';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import gradient from 'gradient-string';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import colors from 'picocolors';
|
|
9
|
+
import { copyTemplates } from './functions/copyTemplates.js';
|
|
10
|
+
import { installDeps } from './functions/installDeps.js';
|
|
11
|
+
import { setup } from './functions/setup.js';
|
|
12
|
+
import { detectPackageManager, textColors } from './utils.js';
|
|
13
|
+
const commandkitGradient = gradient(textColors.commandkit)('CommandKit');
|
|
14
|
+
intro(`Welcome to ${commandkitGradient}!`);
|
|
15
|
+
const dir = path.resolve(process.cwd(), (await text({
|
|
16
|
+
message: 'Enter a project directory:',
|
|
17
|
+
placeholder: 'Leave blank for current directory',
|
|
18
|
+
defaultValue: '.',
|
|
19
|
+
validate: (value) => {
|
|
20
|
+
value = path.resolve(process.cwd(), value);
|
|
21
|
+
let isEmpty;
|
|
22
|
+
try {
|
|
23
|
+
const contents = fs.readdirSync(value);
|
|
24
|
+
isEmpty = contents.length === 0;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
isEmpty = true;
|
|
28
|
+
}
|
|
29
|
+
return isEmpty ? undefined : 'Directory is not empty!';
|
|
30
|
+
},
|
|
31
|
+
})));
|
|
32
|
+
const manager = (await select({
|
|
33
|
+
message: 'Select a package manager:',
|
|
34
|
+
initialValue: detectPackageManager(),
|
|
35
|
+
options: [
|
|
36
|
+
{ label: 'npm', value: 'npm' },
|
|
37
|
+
{ label: 'pnpm', value: 'pnpm' },
|
|
38
|
+
{ label: 'yarn', value: 'yarn' },
|
|
39
|
+
{ label: 'bun', value: 'bun' },
|
|
40
|
+
{ label: 'deno', value: 'deno' },
|
|
41
|
+
],
|
|
42
|
+
}));
|
|
43
|
+
const lang = (await select({
|
|
44
|
+
message: 'Select the language to use:',
|
|
45
|
+
initialValue: 'ts',
|
|
46
|
+
options: [
|
|
47
|
+
{ label: 'TypeScript', value: 'ts' },
|
|
48
|
+
{ label: 'JavaScript', value: 'js' },
|
|
49
|
+
],
|
|
50
|
+
}));
|
|
51
|
+
const token = (await password({
|
|
52
|
+
message: 'Enter your Discord bot token (stored in .env, optional):',
|
|
53
|
+
mask: colors.gray('*'),
|
|
54
|
+
}));
|
|
55
|
+
const gitInit = await confirm({
|
|
56
|
+
message: 'Initialize a git repository?',
|
|
57
|
+
initialValue: true,
|
|
58
|
+
});
|
|
59
|
+
outro(colors.cyan('Setup complete.'));
|
|
60
|
+
await setup({
|
|
61
|
+
manager,
|
|
62
|
+
dir,
|
|
63
|
+
token,
|
|
64
|
+
});
|
|
65
|
+
await copyTemplates({ dir, lang });
|
|
66
|
+
if (gitInit) {
|
|
67
|
+
try {
|
|
68
|
+
execSync('git init', { cwd: dir, stdio: 'pipe' });
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.log(colors.yellow('Warning: Git initialization failed. Make sure Git is installed on your system.'));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
installDeps({
|
|
75
|
+
dir,
|
|
76
|
+
manager,
|
|
77
|
+
lang,
|
|
78
|
+
stdio: 'pipe',
|
|
79
|
+
});
|
|
80
|
+
const command = (cmd) => {
|
|
81
|
+
switch (manager) {
|
|
82
|
+
case 'npm':
|
|
83
|
+
// bun build runs bundler instead of the build script
|
|
84
|
+
case 'bun':
|
|
85
|
+
return `${manager} run ${cmd}`;
|
|
86
|
+
case 'pnpm':
|
|
87
|
+
case 'yarn':
|
|
88
|
+
return `${manager} ${cmd}`;
|
|
89
|
+
case 'deno':
|
|
90
|
+
return `deno task ${cmd}`;
|
|
91
|
+
default:
|
|
92
|
+
return manager;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
console.log(`${gradient(textColors.commandkit)('Thank you for choosing CommandKit!')}
|
|
4
96
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
97
|
+
To start your bot, use the following commands:
|
|
98
|
+
${colors.magenta(command('dev'))} - Run your bot in development mode
|
|
99
|
+
${colors.magenta(command('build'))} - Build your bot for production
|
|
100
|
+
${colors.magenta(command('start'))} - Run your bot in production mode
|
|
101
|
+
|
|
102
|
+
• Documentation: ${colors.blue('https://commandkit.dev')}
|
|
103
|
+
• GitHub: ${colors.blue('https://github.com/underctrl-io/commandkit')}
|
|
104
|
+
• Under Ctrl: ${colors.blue('https://underctrl.io')}
|
|
105
|
+
• Discord community: ${colors.blue('https://ctrl.lol/discord')}
|
|
106
|
+
|
|
107
|
+
Happy coding! 🚀`);
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PackageManager } from './types';
|
|
2
|
+
export declare const textColors: {
|
|
3
|
+
commandkit: string[];
|
|
4
|
+
js: string[];
|
|
5
|
+
ts: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const commands: {
|
|
8
|
+
init: {
|
|
9
|
+
yarn: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function detectPackageManager(): PackageManager;
|
|
13
|
+
export declare function getCommandKitVersion(): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export const textColors = {
|
|
5
|
+
commandkit: ['#fdba74', '#e4a5a2', '#c288de', '#b27bf9'],
|
|
6
|
+
js: ['#f7e01c', '#f7e01c'],
|
|
7
|
+
ts: ['#2480c5', '#2480c5'],
|
|
8
|
+
};
|
|
9
|
+
export const commands = {
|
|
10
|
+
init: {
|
|
11
|
+
yarn: 'yarn set version stable; yarn config set nodeLinker node-modules;',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export function detectPackageManager() {
|
|
15
|
+
const packageManager = process.env.npm_config_user_agent;
|
|
16
|
+
if (packageManager?.includes('pnpm'))
|
|
17
|
+
return 'pnpm';
|
|
18
|
+
if (packageManager?.includes('yarn'))
|
|
19
|
+
return 'yarn';
|
|
20
|
+
if (packageManager?.includes('bun'))
|
|
21
|
+
return 'bun';
|
|
22
|
+
if (packageManager?.includes('npm'))
|
|
23
|
+
return 'npm';
|
|
24
|
+
if (packageManager?.includes('deno'))
|
|
25
|
+
return 'deno';
|
|
26
|
+
return 'npm';
|
|
27
|
+
}
|
|
28
|
+
export function getCommandKitVersion() {
|
|
29
|
+
try {
|
|
30
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
31
|
+
const __dirname = path.dirname(__filename);
|
|
32
|
+
const packageJsonPath = path.resolve(__dirname, '..', 'package.json');
|
|
33
|
+
const packageJson = fs.readJsonSync(packageJsonPath);
|
|
34
|
+
const currentVersion = packageJson.version;
|
|
35
|
+
if (currentVersion.includes('dev.')) {
|
|
36
|
+
return '@dev';
|
|
37
|
+
}
|
|
38
|
+
else if (currentVersion.includes('rc.')) {
|
|
39
|
+
return '@next';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return '@latest';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn('Could not determine create-commandkit version, defaulting to commandkit@latest');
|
|
47
|
+
return '@latest';
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-commandkit",
|
|
3
|
-
"description": "Effortlessly create a CommandKit project
|
|
4
|
-
"version": "1.2.0-
|
|
3
|
+
"description": "Effortlessly create a CommandKit project",
|
|
4
|
+
"version": "1.2.0-rc.10",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"bin": "./dist/index.js",
|
|
@@ -26,25 +26,24 @@
|
|
|
26
26
|
"url": "https://github.com/underctrl-io/commandkit",
|
|
27
27
|
"directory": "packages/create-commandkit"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://commandkit.
|
|
30
|
-
"scripts": {
|
|
31
|
-
"lint": "tsc --noEmit",
|
|
32
|
-
"dev": "tsup --watch",
|
|
33
|
-
"build": "tsup",
|
|
34
|
-
"deploy:package": "npm publish"
|
|
35
|
-
},
|
|
29
|
+
"homepage": "https://commandkit.dev",
|
|
36
30
|
"dependencies": {
|
|
37
|
-
"@clack/prompts": "^0.
|
|
38
|
-
"colors": "^1.4.0",
|
|
31
|
+
"@clack/prompts": "^0.11.0",
|
|
39
32
|
"fs-extra": "^11.1.1",
|
|
40
|
-
"gradient-string": "^
|
|
33
|
+
"gradient-string": "^3.0.0",
|
|
34
|
+
"ora": "^8.0.1",
|
|
35
|
+
"picocolors": "^1.1.1"
|
|
41
36
|
},
|
|
42
37
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^20.11.6",
|
|
44
|
-
"@types/gradient-string": "^1.1.5",
|
|
45
38
|
"@types/fs-extra": "^11.0.4",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
39
|
+
"@types/gradient-string": "^1.1.5",
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"typescript": "^5.8.3",
|
|
42
|
+
"tsconfig": "0.0.0-rc.10"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"check-types": "tsc --noEmit",
|
|
46
|
+
"dev": "tsc --watch",
|
|
47
|
+
"build": "tsc"
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
Thanks for choosing CommandKit to build your Discord bot!
|
|
6
6
|
|
|
7
|
+
## To run this project
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npx commandkit dev
|
|
11
|
+
```
|
|
12
|
+
|
|
7
13
|
## Useful links
|
|
8
14
|
|
|
9
|
-
- [Documentation](https://commandkit.
|
|
15
|
+
- [Documentation](https://commandkit.dev)
|
|
10
16
|
- [Discord](https://ctrl.lol/discord)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="node_modules/commandkit-types/index.d.ts" />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"module": "Preserve",
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"skipDefaultLibCheck": true,
|
|
13
|
+
"noUncheckedIndexedAccess": true,
|
|
14
|
+
"removeComments": true,
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"checkJs": false,
|
|
17
|
+
"strict": true,
|
|
18
|
+
"alwaysStrict": true,
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"declaration": false,
|
|
21
|
+
"jsx": "react-jsx",
|
|
22
|
+
"jsxImportSource": "commandkit",
|
|
23
|
+
"baseUrl": ".",
|
|
24
|
+
"paths": {
|
|
25
|
+
"@/*": ["./src/*"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"include": ["src", "commandkit.config.mjs", "commandkit-env.d.ts"],
|
|
29
|
+
"exclude": ["dist", "node_modules", ".commandkit"]
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import('commandkit').CommandData}
|
|
3
|
+
*/
|
|
4
|
+
export const command = {
|
|
5
|
+
name: 'ping',
|
|
6
|
+
description: "Ping the bot to check if it's online.",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('commandkit').ChatInputCommandContext} ctx
|
|
11
|
+
*/
|
|
12
|
+
export const chatInput = async (ctx) => {
|
|
13
|
+
const latency = (ctx.client.ws.ping ?? -1).toString();
|
|
14
|
+
const response = `Pong! Latency: ${latency}ms`;
|
|
15
|
+
|
|
16
|
+
await ctx.interaction.reply(response);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {import('commandkit').MessageCommandContext} ctx
|
|
21
|
+
*/
|
|
22
|
+
export const message = async (ctx) => {
|
|
23
|
+
const latency = (ctx.client.ws.ping ?? -1).toString();
|
|
24
|
+
const response = `Pong! Latency: ${latency}ms`;
|
|
25
|
+
|
|
26
|
+
await ctx.message.reply(response);
|
|
27
|
+
};
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
Thanks for choosing CommandKit to build your Discord bot!
|
|
6
6
|
|
|
7
|
+
## To run this project
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npx commandkit dev
|
|
11
|
+
```
|
|
12
|
+
|
|
7
13
|
## Useful links
|
|
8
14
|
|
|
9
|
-
- [Documentation](https://commandkit.
|
|
15
|
+
- [Documentation](https://commandkit.dev)
|
|
10
16
|
- [Discord](https://ctrl.lol/discord)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="node_modules/commandkit-types/index.d.ts" />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ChatInputCommand, MessageCommand, CommandData } from 'commandkit';
|
|
2
|
+
|
|
3
|
+
export const command: CommandData = {
|
|
4
|
+
name: 'ping',
|
|
5
|
+
description: "Ping the bot to check if it's online.",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const chatInput: ChatInputCommand = async (ctx) => {
|
|
9
|
+
const latency = (ctx.client.ws.ping ?? -1).toString();
|
|
10
|
+
const response = `Pong! Latency: ${latency}ms`;
|
|
11
|
+
|
|
12
|
+
await ctx.interaction.reply(response);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const message: MessageCommand = async (ctx) => {
|
|
16
|
+
const latency = (ctx.client.ws.ping ?? -1).toString();
|
|
17
|
+
const response = `Pong! Latency: ${latency}ms`;
|
|
18
|
+
|
|
19
|
+
await ctx.message.reply(response);
|
|
20
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"module": "Preserve",
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"skipDefaultLibCheck": true,
|
|
13
|
+
"noUncheckedIndexedAccess": true,
|
|
14
|
+
"removeComments": true,
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"alwaysStrict": true,
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"declaration": false,
|
|
20
|
+
"jsx": "react-jsx",
|
|
21
|
+
"jsxImportSource": "commandkit",
|
|
22
|
+
"baseUrl": ".",
|
|
23
|
+
"paths": {
|
|
24
|
+
"@/*": ["./src/*"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"include": ["src", "commandkit.config.ts", "commandkit-env.d.ts"],
|
|
28
|
+
"exclude": ["dist", "node_modules", ".commandkit"]
|
|
29
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
/** @type {import('commandkit').CommandData} */
|
|
3
|
-
data: {
|
|
4
|
-
name: 'ping',
|
|
5
|
-
description: 'Replies with Pong',
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {import('commandkit').SlashCommandProps} param0
|
|
10
|
-
*/
|
|
11
|
-
run: ({ interaction }) => {
|
|
12
|
-
interaction.reply('Pong!');
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
/** @type {import('commandkit').CommandOptions} */
|
|
16
|
-
options: {
|
|
17
|
-
// https://commandkit.js.org/typedef/CommandOptions
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require('dotenv/config');
|
|
2
|
-
|
|
3
|
-
const { Client, IntentsBitField } = require('discord.js');
|
|
4
|
-
const { CommandKit } = require('commandkit');
|
|
5
|
-
const { join } = require('path');
|
|
6
|
-
|
|
7
|
-
const client = new Client({
|
|
8
|
-
intents: [
|
|
9
|
-
IntentsBitField.Flags.Guilds,
|
|
10
|
-
IntentsBitField.Flags.GuildMembers,
|
|
11
|
-
IntentsBitField.Flags.GuildMessages,
|
|
12
|
-
IntentsBitField.Flags.MessageContent,
|
|
13
|
-
],
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
new CommandKit({
|
|
17
|
-
client,
|
|
18
|
-
eventsPath: join(__dirname, 'events'),
|
|
19
|
-
commandsPath: join(__dirname, 'commands'),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
client.login(process.env.TOKEN);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Welcome to CommandKit
|
|
2
|
-
|
|
3
|
-
> This project was generated by [create-commandkit](https://npmjs.com/package/create-commandkit).
|
|
4
|
-
|
|
5
|
-
Thanks for choosing CommandKit to build your Discord bot!
|
|
6
|
-
|
|
7
|
-
## Useful links
|
|
8
|
-
|
|
9
|
-
- [Documentation](https://commandkit.js.org)
|
|
10
|
-
- [Discord](https://ctrl.lol/discord)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** @type {import('commandkit').CommandData} */
|
|
2
|
-
export const data = {
|
|
3
|
-
name: 'ping',
|
|
4
|
-
description: 'Replies with Pong',
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('commandkit').SlashCommandProps} param0
|
|
9
|
-
*/
|
|
10
|
-
export const run = ({ interaction }) => {
|
|
11
|
-
interaction.reply('Pong!');
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/** @type {import('commandkit').CommandOptions} */
|
|
15
|
-
export const options = {
|
|
16
|
-
// https://commandkit.js.org/typedef/CommandOptions
|
|
17
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
|
|
3
|
-
import { Client, IntentsBitField } from 'discord.js';
|
|
4
|
-
import { CommandKit } from 'commandkit';
|
|
5
|
-
|
|
6
|
-
import { join, dirname } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
const client = new Client({
|
|
12
|
-
intents: [
|
|
13
|
-
IntentsBitField.Flags.Guilds,
|
|
14
|
-
IntentsBitField.Flags.GuildMembers,
|
|
15
|
-
IntentsBitField.Flags.GuildMessages,
|
|
16
|
-
IntentsBitField.Flags.MessageContent,
|
|
17
|
-
],
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
new CommandKit({
|
|
21
|
-
client,
|
|
22
|
-
eventsPath: join(__dirname, 'events'),
|
|
23
|
-
commandsPath: join(__dirname, 'commands'),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
client.login(process.env.TOKEN);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CommandData,
|
|
3
|
-
SlashCommandProps,
|
|
4
|
-
CommandOptions,
|
|
5
|
-
} from 'commandkit';
|
|
6
|
-
|
|
7
|
-
export const data: CommandData = {
|
|
8
|
-
name: 'ping',
|
|
9
|
-
description: 'Replies with Pong',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const run = ({ interaction }: SlashCommandProps) => {
|
|
13
|
-
interaction.reply('Pong!');
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const options: CommandOptions = {
|
|
17
|
-
// https://commandkit.js.org/typedef/CommandOptions
|
|
18
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
|
|
3
|
-
import { Client, IntentsBitField } from 'discord.js';
|
|
4
|
-
import { CommandKit } from 'commandkit';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
|
|
7
|
-
const client = new Client({
|
|
8
|
-
intents: [
|
|
9
|
-
IntentsBitField.Flags.Guilds,
|
|
10
|
-
IntentsBitField.Flags.GuildMembers,
|
|
11
|
-
IntentsBitField.Flags.GuildMessages,
|
|
12
|
-
IntentsBitField.Flags.MessageContent,
|
|
13
|
-
],
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
new CommandKit({
|
|
17
|
-
client,
|
|
18
|
-
eventsPath: join(__dirname, 'events'),
|
|
19
|
-
commandsPath: join(__dirname, 'commands'),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
client.login(process.env.TOKEN);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"lib": ["ES2022"],
|
|
5
|
-
"target": "ES2022",
|
|
6
|
-
"moduleResolution": "Bundler",
|
|
7
|
-
"module": "ES2022",
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"noUncheckedIndexedAccess": true,
|
|
12
|
-
"removeComments": true,
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
"declaration": false
|
|
17
|
-
},
|
|
18
|
-
"include": ["src"],
|
|
19
|
-
"exclude": ["dist", "node_modules", ".commandkit"]
|
|
20
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Welcome to CommandKit
|
|
2
|
-
|
|
3
|
-
> This project was generated by [create-commandkit](https://npmjs.com/package/create-commandkit).
|
|
4
|
-
|
|
5
|
-
Thanks for choosing CommandKit to build your Discord bot!
|
|
6
|
-
|
|
7
|
-
## Useful links
|
|
8
|
-
|
|
9
|
-
- [Documentation](https://commandkit.js.org)
|
|
10
|
-
- [Discord](https://ctrl.lol/discord)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CommandData,
|
|
3
|
-
SlashCommandProps,
|
|
4
|
-
CommandOptions,
|
|
5
|
-
} from 'commandkit';
|
|
6
|
-
|
|
7
|
-
export const data: CommandData = {
|
|
8
|
-
name: 'ping',
|
|
9
|
-
description: 'Replies with Pong',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const run = ({ interaction }: SlashCommandProps) => {
|
|
13
|
-
interaction.reply('Pong!');
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const options: CommandOptions = {
|
|
17
|
-
// https://commandkit.js.org/typedef/CommandOptions
|
|
18
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
|
|
3
|
-
import { Client, IntentsBitField } from 'discord.js';
|
|
4
|
-
import { CommandKit } from 'commandkit';
|
|
5
|
-
|
|
6
|
-
import { join, dirname } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
const client = new Client({
|
|
12
|
-
intents: [
|
|
13
|
-
IntentsBitField.Flags.Guilds,
|
|
14
|
-
IntentsBitField.Flags.GuildMembers,
|
|
15
|
-
IntentsBitField.Flags.GuildMessages,
|
|
16
|
-
IntentsBitField.Flags.MessageContent,
|
|
17
|
-
],
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
new CommandKit({
|
|
21
|
-
client,
|
|
22
|
-
eventsPath: join(__dirname, 'events'),
|
|
23
|
-
commandsPath: join(__dirname, 'commands'),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
client.login(process.env.TOKEN);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"lib": ["ES2022"],
|
|
5
|
-
"target": "ES2022",
|
|
6
|
-
"moduleResolution": "Bundler",
|
|
7
|
-
"module": "ES2022",
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"noUncheckedIndexedAccess": true,
|
|
12
|
-
"removeComments": true,
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
"declaration": false
|
|
17
|
-
},
|
|
18
|
-
"include": ["src"],
|
|
19
|
-
"exclude": ["dist", "node_modules", ".commandkit"]
|
|
20
|
-
}
|