Skip to content

Commit 0bffa78

Browse files
committed
feat: dynamic create-commandkit
1 parent 562ef1a commit 0bffa78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3717
-0
lines changed

examples/basic-js/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# dependencies
2+
node_modules
3+
4+
# build output
5+
build
6+
out
7+
dist
8+
9+
# commandkit
10+
.commandkit
11+
dist
12+
compiled-commandkit.config.mjs
13+
14+
# env
15+
**/*.env*
16+
!**/*.env.example*
17+
18+
# logging
19+
logs
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
lerna-debug.log*
25+
.pnpm-debug.log*
26+
27+
# yarn v2+
28+
.yarn/cache
29+
.yarn/unplugged
30+
.yarn/build-state.yml
31+
.yarn/install-state.gz
32+
.pnp.*
33+
34+
# other
35+
**/*.DS_Store
36+
.temp-example

examples/basic-js/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Welcome to CommandKit + JavaScript
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+
## To run this project
8+
9+
```
10+
npx commandkit dev
11+
```
12+
13+
## Useful links
14+
15+
- [Documentation](https://commandkit.dev)
16+
- [Discord](https://ctrl.lol/discord)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="node_modules/commandkit-types/index.d.ts" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineConfig } from 'commandkit/config';
2+
3+
export default defineConfig({});

examples/basic-js/jsconfig.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

examples/basic-js/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "commandkit-basic-js",
3+
"description": "A CommandKit project using JavaScript",
4+
"version": "0.1.0",
5+
"type": "module",
6+
"private": true,
7+
"main": "dist/index.js",
8+
"scripts": {
9+
"dev": "commandkit dev",
10+
"build": "commandkit build",
11+
"start": "commandkit start"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^24.0.10",
15+
"typescript": "^5.8.3"
16+
},
17+
"dependencies": {
18+
"commandkit": "^1.2.0-rc.12",
19+
"discord.js": "^14.23.2"
20+
}
21+
}

examples/basic-js/src/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Client } from 'discord.js';
2+
3+
const client = new Client({
4+
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
5+
});
6+
7+
export default client;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Logger } from 'commandkit/logger';
2+
3+
/**
4+
* @type {import('commandkit').EventHandler<'clientReady'>}
5+
*/
6+
const handler = async (client) => {
7+
Logger.info(`Logged in as ${client.user.username}!`);
8+
};
9+
10+
export default handler;

examples/basic-ts/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# dependencies
2+
node_modules
3+
4+
# build output
5+
build
6+
out
7+
dist
8+
9+
# commandkit
10+
.commandkit
11+
dist
12+
compiled-commandkit.config.mjs
13+
14+
# env
15+
**/*.env*
16+
!**/*.env.example*
17+
18+
# logging
19+
logs
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
lerna-debug.log*
25+
.pnpm-debug.log*
26+
27+
# yarn v2+
28+
.yarn/cache
29+
.yarn/unplugged
30+
.yarn/build-state.yml
31+
.yarn/install-state.gz
32+
.pnp.*
33+
34+
# other
35+
**/*.DS_Store
36+
.temp-example

0 commit comments

Comments
 (0)