create-commandkit 1.1.4-dev.20250208091526 → 1.1.4-dev.20250215123740

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.
Files changed (52) hide show
  1. package/dist/index.js +11 -2
  2. package/package.json +7 -7
  3. package/templates/JavaScript/app/cjs/src/app/commands/ping/command.js +23 -0
  4. package/templates/JavaScript/app/cjs/src/app/events/ready/log.js +6 -0
  5. package/templates/JavaScript/app/cjs/src/app/locales/en-US/ping.json +9 -0
  6. package/templates/JavaScript/app/cjs/src/index.js +19 -0
  7. package/templates/{TypeScript → JavaScript/app}/cjs/tsconfig.json +5 -2
  8. package/templates/JavaScript/app/esm/src/app/commands/ping/command.js +28 -0
  9. package/templates/JavaScript/app/esm/src/app/events/ready/log.js +6 -0
  10. package/templates/JavaScript/app/esm/src/app/locales/en-US/ping.json +9 -0
  11. package/templates/JavaScript/app/esm/src/index.js +19 -0
  12. package/templates/{TypeScript → JavaScript/app}/esm/tsconfig.json +5 -2
  13. package/templates/JavaScript/{cjs → legacy/cjs}/src/index.js +3 -3
  14. package/templates/JavaScript/legacy/esm/commandkit.mjs +6 -0
  15. package/templates/JavaScript/{esm → legacy/esm}/src/index.js +6 -9
  16. package/templates/TypeScript/app/cjs/README.md +10 -0
  17. package/templates/TypeScript/app/cjs/commandkit.mjs +6 -0
  18. package/templates/TypeScript/app/cjs/src/app/commands/ping/command.ts +24 -0
  19. package/templates/TypeScript/app/cjs/src/app/events/ready/log.ts +5 -0
  20. package/templates/TypeScript/app/cjs/src/app/locales/en-US/ping.json +9 -0
  21. package/templates/TypeScript/app/cjs/src/index.ts +19 -0
  22. package/templates/TypeScript/app/cjs/tsconfig.json +23 -0
  23. package/templates/TypeScript/app/esm/README.md +10 -0
  24. package/templates/TypeScript/app/esm/commandkit.mjs +6 -0
  25. package/templates/TypeScript/app/esm/src/app/commands/ping/command.ts +24 -0
  26. package/templates/TypeScript/app/esm/src/app/events/ready/log.ts +5 -0
  27. package/templates/TypeScript/app/esm/src/app/locales/en-US/ping.json +9 -0
  28. package/templates/TypeScript/app/esm/src/index.ts +19 -0
  29. package/templates/TypeScript/app/esm/tsconfig.json +23 -0
  30. package/templates/TypeScript/legacy/cjs/README.md +10 -0
  31. package/templates/TypeScript/{cjs → legacy/cjs}/src/index.ts +3 -3
  32. package/templates/TypeScript/legacy/cjs/tsconfig.json +23 -0
  33. package/templates/TypeScript/legacy/esm/README.md +10 -0
  34. package/templates/TypeScript/legacy/esm/commandkit.mjs +6 -0
  35. package/templates/TypeScript/{esm → legacy/esm}/src/index.ts +6 -9
  36. package/templates/TypeScript/legacy/esm/tsconfig.json +23 -0
  37. /package/templates/JavaScript/{cjs → app/cjs}/README.md +0 -0
  38. /package/templates/JavaScript/{esm → app/cjs}/commandkit.mjs +0 -0
  39. /package/templates/JavaScript/{esm → app/esm}/README.md +0 -0
  40. /package/templates/{TypeScript → JavaScript/app}/esm/commandkit.mjs +0 -0
  41. /package/templates/{TypeScript → JavaScript/legacy}/cjs/README.md +0 -0
  42. /package/templates/JavaScript/{cjs → legacy/cjs}/commandkit.cjs +0 -0
  43. /package/templates/JavaScript/{cjs → legacy/cjs}/src/commands/General/ping.js +0 -0
  44. /package/templates/JavaScript/{cjs → legacy/cjs}/src/events/ready/ready.js +0 -0
  45. /package/templates/{TypeScript → JavaScript/legacy}/esm/README.md +0 -0
  46. /package/templates/JavaScript/{esm → legacy/esm}/src/commands/General/ping.js +0 -0
  47. /package/templates/JavaScript/{esm → legacy/esm}/src/events/ready/ready.js +0 -0
  48. /package/templates/TypeScript/{cjs → legacy/cjs}/commandkit.cjs +0 -0
  49. /package/templates/TypeScript/{cjs → legacy/cjs}/src/commands/General/ping.ts +0 -0
  50. /package/templates/TypeScript/{cjs → legacy/cjs}/src/events/ready/ready.ts +0 -0
  51. /package/templates/TypeScript/{esm → legacy/esm}/src/commands/General/ping.ts +0 -0
  52. /package/templates/TypeScript/{esm → legacy/esm}/src/events/ready/ready.ts +0 -0
package/dist/index.js CHANGED
@@ -1,7 +1,16 @@
1
1
  #!/usr/bin/env node
2
- var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:true});import{intro,text,select,password,confirm,outro}from"@clack/prompts";import colors from"colors";import gradient from"gradient-string";import path from"node:path";import url from"node:url";var __dirname=path.dirname(url.fileURLToPath(import.meta.url));var templates={js:{esm:path.join(__dirname,"..","templates","JavaScript","esm"),cjs:path.join(__dirname,"..","templates","JavaScript","cjs")},ts:{esm:path.join(__dirname,"..","templates","TypeScript","esm"),cjs:path.join(__dirname,"..","templates","TypeScript","cjs")}};var textColors={commandkit:["#fdba74","#e4a5a2","#c288de","#b27bf9"],import:["#c586c0","#c586c0"],export:["#569cd6","#569cd6"],require:["#dcdcaa","#dcdcaa"],module:["#4ec9b0","#4ec9b0"],js:["#f7e01c","#f7e01c"],ts:["#2480c5","#2480c5"]};var baseDependencies=["commandkit","discord.js","dotenv"];var dependencies={js:{dependencies:baseDependencies},ts:{dependencies:baseDependencies,devDependencies:["@types/node","typescript"]}};var commands={init:{npm:"npm init -y",yarn:"yarn init -y; yarn config set nodeLinker node-modules; yarn set version stable",pnpm:"pnpm init"}};var hints={import:gradient(textColors.import)("import"),export:gradient(textColors.export)("export"),require:gradient(textColors.require)("require"),module:gradient(textColors.module)("exports"),javascript:gradient(textColors.js)("JavaScript"),typescript:gradient(textColors.ts)("TypeScript")};var commandkit=gradient(textColors.commandkit)("CommandKit");var outroMsg=`
2
+ var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:true});import{intro,text,select,password,confirm,outro}from"@clack/prompts";import colors from"picocolors";import gradient from"gradient-string";import path from"node:path";import url from"node:url";var __dirname=path.dirname(url.fileURLToPath(import.meta.url));var templates={js:{app:{esm:path.join(__dirname,"..","templates","JavaScript","app","esm"),cjs:path.join(__dirname,"..","templates","JavaScript","app","cjs")},legacy:{esm:path.join(__dirname,"..","templates","JavaScript","legacy","esm"),cjs:path.join(__dirname,"..","templates","JavaScript","legacy","cjs")}},ts:{app:{esm:path.join(__dirname,"..","templates","TypeScript","app","esm"),cjs:path.join(__dirname,"..","templates","TypeScript","app","cjs")},legacy:{esm:path.join(__dirname,"..","templates","TypeScript","legacy","esm"),cjs:path.join(__dirname,"..","templates","TypeScript","legacy","cjs")}}};var textColors={commandkit:["#fdba74","#e4a5a2","#c288de","#b27bf9"],import:["#c586c0","#c586c0"],export:["#569cd6","#569cd6"],require:["#dcdcaa","#dcdcaa"],module:["#4ec9b0","#4ec9b0"],js:["#f7e01c","#f7e01c"],ts:["#2480c5","#2480c5"],app:["#e4a5a2","#e4a5a2"],legacy:["#dcdcaa","#dcdcaa"]};var baseDependencies=["commandkit","discord.js"];var dependencies={js:{dependencies:baseDependencies},ts:{dependencies:baseDependencies,devDependencies:["@types/node","typescript"]}};var commands={init:{npm:"npm init -y",yarn:"yarn init -y; yarn config set nodeLinker node-modules; yarn set version stable",pnpm:"pnpm init",bun:"bun init -y"}};var hints={import:gradient(textColors.import)("import"),export:gradient(textColors.export)("export"),require:gradient(textColors.require)("require"),module:gradient(textColors.module)("exports"),javascript:gradient(textColors.js)("JavaScript"),typescript:gradient(textColors.ts)("TypeScript")};var commandkit=gradient(textColors.commandkit)("CommandKit");var outroMsg=__name(({manager:manager2})=>`
3
3
  ${gradient(textColors.commandkit)("Thank you for choosing CommandKit!")}
4
4
 
5
+ To start your bot, use the following commands:
6
+ ${colors.magenta(`${manager2} run dev`)} - Run your bot in development mode
7
+ ${colors.magenta(`${manager2} run build`)} - Build your bot for production
8
+ ${colors.magenta(`${manager2} run start`)} - Run your bot in production mode
9
+
5
10
  \u2022 Documentation: ${colors.blue("https://commandkit.dev")}
11
+ \u2022 GitHub: ${colors.blue("https://github.com/underctrl-io/commandkit")}
12
+ \u2022 UnderCtrl: ${colors.blue("https://underctrl.io")}
6
13
  \u2022 Join us on Discord: ${colors.blue("https://ctrl.lol/discord")}
7
- `;import{execSync}from"child_process";import fs from"fs-extra";import path2 from"node:path";async function setup({manager:manager2,type:type2,token:token2,dir:dir2,stdio="pipe"}){await fs.emptyDir(dir2);execSync(commands.init[manager2],{cwd:dir2,stdio});const packageJsonPath=path2.join(dir2,"package.json");const packageJson=await fs.readJSON(packageJsonPath);delete packageJson.main;packageJson.name=packageJson.name.toLowerCase();packageJson.type=type2=="esm"?"module":"commonjs";packageJson.version="0.0.0";packageJson.scripts={dev:"commandkit dev",build:"commandkit build",start:"commandkit start"};await fs.writeJSON(packageJsonPath,packageJson,{spaces:2});await fs.writeFile(`${dir2}/.env`,`TOKEN="${token2}"`)}__name(setup,"setup");import{execSync as execSync2}from"node:child_process";function installDeps({manager:manager2,dir:dir2,lang:lang2,stdio="pipe"}){const depsCommand=`${manager2} add ${dependencies[lang2].dependencies.join(" ")}`;const devDepsCommand=`${manager2} add ${dependencies.ts.devDependencies.join(" ")}`;execSync2(depsCommand,{cwd:dir2,stdio});if(lang2=="ts"){execSync2(devDepsCommand,{cwd:dir2,stdio})}}__name(installDeps,"installDeps");import fs2 from"fs-extra";async function copyTemplates({type:type2,dir:dir2,lang:lang2}){await fs2.copy(templates[lang2][type2],dir2)}__name(copyTemplates,"copyTemplates");import path3 from"node:path";import colors2 from"colors";import fs3 from"fs-extra";console.clear();await intro(`Welcome to ${commandkit}!`);var dir=path3.resolve(process.cwd(),await text({message:"Enter a project directory:",placeholder:"Leave blank for current directory",defaultValue:".",validate:__name(value=>{value=path3.resolve(process.cwd(),value);let isEmpty;try{const contents=fs3.readdirSync(value);isEmpty=contents.length===0}catch{isEmpty=true}return isEmpty?void 0:"Directory is not empty!"},"validate")}));var manager=await select({message:"Select a package manager:",options:[{label:"npm",value:"npm"},{label:"pnpm",value:"pnpm"},{label:"yarn",value:"yarn"}]});var lang=await select({message:"Select the language to use:",options:[{label:"JavaScript",value:"js"},{label:"TypeScript",value:"ts"}]});var type=await select({message:"Select a module type:",options:[{label:"CommonJS",value:"cjs",hint:`${hints.require} & ${hints.module}`},{label:"ES Modules",value:"esm",hint:`${hints.import} & ${hints.export}`}]});var token=await password({message:"Enter your bot token:",mask:colors2.gray("*")});var installNow=await confirm({message:"Install dependencies now?",initialValue:true});outro(colors2.cyan("Setup complete."));await setup({manager,dir,token,type});await copyTemplates({type,dir,lang});if(installNow){await installDeps({manager,dir,lang:"js",stdio:"inherit"})}console.log(outroMsg);
14
+
15
+ Happy coding! \u{1F680}
16
+ `,"outroMsg");import{execSync}from"child_process";import fs from"fs-extra";import path2 from"node:path";async function setup({manager:manager2,type:type2,token:token2,dir:dir2,stdio="pipe"}){await fs.emptyDir(dir2);execSync(commands.init[manager2],{cwd:dir2,stdio});const packageJsonPath=path2.join(dir2,"package.json");const packageJson=await fs.readJSON(packageJsonPath);delete packageJson.main;packageJson.name=packageJson.name.toLowerCase();packageJson.type=type2=="esm"?"module":"commonjs";packageJson.version="0.0.0";packageJson.scripts={dev:"commandkit dev",build:"commandkit build",start:"commandkit start"};await fs.writeJSON(packageJsonPath,packageJson,{spaces:2});await fs.writeFile(`${dir2}/.env`,`DISCORD_TOKEN="${token2}"`)}__name(setup,"setup");import{execSync as execSync2}from"node:child_process";function installDeps({manager:manager2,dir:dir2,lang:lang2,stdio="pipe"}){const depsCommand=`${manager2} add ${dependencies[lang2].dependencies.join(" ")}`;const devDepsCommand=`${manager2} add ${dependencies.ts.devDependencies.join(" ")}`;execSync2(depsCommand,{cwd:dir2,stdio});if(lang2=="ts"){execSync2(devDepsCommand,{cwd:dir2,stdio})}}__name(installDeps,"installDeps");import fs2 from"fs-extra";async function copyTemplates({type:type2,dir:dir2,lang:lang2,handler:handler2}){await fs2.copy(templates[lang2][handler2][type2],dir2)}__name(copyTemplates,"copyTemplates");import path3 from"node:path";import colors2 from"picocolors";import fs3 from"fs-extra";import{execSync as execSync3}from"node:child_process";async function initializeGit(dir2){try{execSync3("git init",{cwd:dir2,stdio:"pipe"})}catch{}}__name(initializeGit,"initializeGit");console.clear();await intro(`Welcome to ${commandkit}!`);var dir=path3.resolve(process.cwd(),await text({message:"Enter a project directory:",placeholder:"Leave blank for current directory",defaultValue:".",validate:__name(value=>{value=path3.resolve(process.cwd(),value);let isEmpty;try{const contents=fs3.readdirSync(value);isEmpty=contents.length===0}catch{isEmpty=true}return isEmpty?void 0:"Directory is not empty!"},"validate")}));var manager=await select({message:"Select a package manager:",initialValue:"npm",options:[{label:"npm",value:"npm"},{label:"pnpm",value:"pnpm"},{label:"yarn",value:"yarn"},{label:"bun",value:"bun"}]});var lang=await select({message:"Select the language to use:",initialValue:"ts",options:[{label:"JavaScript",value:"js"},{label:"TypeScript",value:"ts"}]});var handler=await select({message:"Select a command handler:",initialValue:"app",options:[{label:"App",value:"app",hint:"recommended"},{label:"Legacy",value:"legacy"}]});var type=await select({message:"Select a module type:",initialValue:"esm",options:[{label:"CommonJS",value:"cjs",hint:`${hints.require} & ${hints.module}`},{label:"ES Modules",value:"esm",hint:`${hints.import} & ${hints.export}`}]});var token=await password({message:"Enter your bot token (stored in .env):",mask:colors2.gray("*")});var installNow=await confirm({message:"Install dependencies now?",initialValue:true});var gitInit=await confirm({message:"Initialize a git repository?",initialValue:true});outro(colors2.cyan("Setup complete."));await setup({manager,dir,token,type});await copyTemplates({type,dir,lang,handler});if(gitInit){await initializeGit(dir)}if(installNow){await installDeps({manager,dir,lang:"js",stdio:"inherit"})}console.log(outroMsg({manager}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-commandkit",
3
3
  "description": "Effortlessly create a CommandKit project",
4
- "version": "1.1.4-dev.20250208091526",
4
+ "version": "1.1.4-dev.20250215123740",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "bin": "./dist/index.js",
@@ -35,16 +35,16 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@clack/prompts": "^0.7.0",
38
- "colors": "^1.4.0",
39
38
  "fs-extra": "^11.1.1",
40
- "gradient-string": "^2.0.2"
39
+ "gradient-string": "^2.0.2",
40
+ "picocolors": "^1.1.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "^20.11.6",
44
- "@types/gradient-string": "^1.1.5",
45
43
  "@types/fs-extra": "^11.0.4",
46
- "typescript": "^5.3.3",
44
+ "@types/gradient-string": "^1.1.5",
45
+ "@types/node": "^20.11.6",
47
46
  "tsconfig": "workspace:*",
48
- "tsup": "^8.0.1"
47
+ "tsup": "^8.0.1",
48
+ "typescript": "^5.3.3"
49
49
  }
50
50
  }
@@ -0,0 +1,23 @@
1
+ // import { SlashCommandContext, MessageCommandContext } from 'commandkit';
2
+ module.exports.command = {
3
+ name: 'ping',
4
+ description: "Ping the bot to check if it's online.",
5
+ };
6
+
7
+ module.exports.chatInput = async (ctx) => {
8
+ const { t } = ctx.locale();
9
+
10
+ const latency = ctx.client.ws.ping ?? -1;
11
+ const response = await t('ping_response', { latency });
12
+
13
+ await ctx.interaction.reply(response);
14
+ };
15
+
16
+ module.exports.message = async (ctx) => {
17
+ const { t } = ctx.locale();
18
+
19
+ const latency = ctx.client.ws.ping ?? -1;
20
+ const response = await t('ping_response', { latency });
21
+
22
+ await ctx.message.reply(response);
23
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {import('discord.js').Client<true>} client
3
+ */
4
+ module.exports = (client) => {
5
+ console.log(`Logged in as ${client.user.username}!`);
6
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "command": {
3
+ "name": "ping",
4
+ "description": "Ping the bot to check if it's online."
5
+ },
6
+ "response": {
7
+ "ping_response": "The ping is `{latency}ms`."
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ process.loadEnvFile();
2
+
3
+ const { Client, IntentsBitField } = require('discord.js');
4
+ const { CommandKit } = require('commandkit');
5
+
6
+ const client = new Client({
7
+ intents: [
8
+ IntentsBitField.Flags.Guilds,
9
+ IntentsBitField.Flags.GuildMembers,
10
+ IntentsBitField.Flags.GuildMessages,
11
+ IntentsBitField.Flags.MessageContent,
12
+ ],
13
+ });
14
+
15
+ const commandkit = new CommandKit({
16
+ client,
17
+ });
18
+
19
+ commandkit.start(process.env.DISCORD_TOKEN);
@@ -4,7 +4,7 @@
4
4
  "lib": ["ES2022"],
5
5
  "target": "ES2022",
6
6
  "moduleResolution": "Bundler",
7
- "module": "ES2022",
7
+ "module": "Preserve",
8
8
  "esModuleInterop": true,
9
9
  "resolveJsonModule": true,
10
10
  "skipLibCheck": true,
@@ -13,7 +13,10 @@
13
13
  "allowJs": true,
14
14
  "strict": true,
15
15
  "noEmit": true,
16
- "declaration": false
16
+ "declaration": false,
17
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
17
20
  },
18
21
  "include": ["src"],
19
22
  "exclude": ["dist", "node_modules", ".commandkit"]
@@ -0,0 +1,28 @@
1
+ export const command = {
2
+ name: 'ping',
3
+ description: "Ping the bot to check if it's online.",
4
+ };
5
+
6
+ /**
7
+ * @param {import('commandkit').SlashCommandContext} ctx
8
+ */
9
+ export async function chatInput(ctx) {
10
+ const { t } = ctx.locale();
11
+
12
+ const latency = ctx.client.ws.ping ?? -1;
13
+ const response = await t('ping_response', { latency });
14
+
15
+ await ctx.interaction.reply(response);
16
+ }
17
+
18
+ /**
19
+ * @param {import('commandkit').MessageCommandContext} ctx
20
+ */
21
+ export async function message(ctx) {
22
+ const { t } = ctx.locale();
23
+
24
+ const latency = ctx.client.ws.ping ?? -1;
25
+ const response = await t('ping_response', { latency });
26
+
27
+ await ctx.message.reply(response);
28
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {import('discord.js').Client<true>} client
3
+ */
4
+ export default function log(client) {
5
+ console.log(`Logged in as ${client.user.username}!`);
6
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "command": {
3
+ "name": "ping",
4
+ "description": "Ping the bot to check if it's online."
5
+ },
6
+ "response": {
7
+ "ping_response": "The ping is `{latency}ms`."
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ process.loadEnvFile();
2
+
3
+ import { Client, IntentsBitField } from 'discord.js';
4
+ import { CommandKit } from 'commandkit';
5
+
6
+ const client = new Client({
7
+ intents: [
8
+ IntentsBitField.Flags.Guilds,
9
+ IntentsBitField.Flags.GuildMembers,
10
+ IntentsBitField.Flags.GuildMessages,
11
+ IntentsBitField.Flags.MessageContent,
12
+ ],
13
+ });
14
+
15
+ const commandkit = new CommandKit({
16
+ client,
17
+ });
18
+
19
+ await commandkit.start(process.env.DISCORD_TOKEN);
@@ -4,7 +4,7 @@
4
4
  "lib": ["ES2022"],
5
5
  "target": "ES2022",
6
6
  "moduleResolution": "Bundler",
7
- "module": "ES2022",
7
+ "module": "Preserve",
8
8
  "esModuleInterop": true,
9
9
  "resolveJsonModule": true,
10
10
  "skipLibCheck": true,
@@ -13,7 +13,10 @@
13
13
  "allowJs": true,
14
14
  "strict": true,
15
15
  "noEmit": true,
16
- "declaration": false
16
+ "declaration": false,
17
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
17
20
  },
18
21
  "include": ["src"],
19
22
  "exclude": ["dist", "node_modules", ".commandkit"]
@@ -1,4 +1,4 @@
1
- require('dotenv/config');
1
+ process.loadEnvFile();
2
2
 
3
3
  const { Client, IntentsBitField } = require('discord.js');
4
4
  const { CommandKit } = require('commandkit');
@@ -13,10 +13,10 @@ const client = new Client({
13
13
  ],
14
14
  });
15
15
 
16
- new CommandKit({
16
+ const commandkit = new CommandKit({
17
17
  client,
18
18
  eventsPath: join(__dirname, 'events'),
19
19
  commandsPath: join(__dirname, 'commands'),
20
20
  });
21
21
 
22
- client.login(process.env.TOKEN);
22
+ commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'commandkit';
2
+
3
+ export default defineConfig({
4
+ src: 'src',
5
+ main: 'index.js',
6
+ });
@@ -1,12 +1,9 @@
1
- import 'dotenv/config';
1
+ process.loadEnvFile();
2
2
 
3
3
  import { Client, IntentsBitField } from 'discord.js';
4
4
  import { CommandKit } from 'commandkit';
5
5
 
6
- import { join, dirname } from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
-
9
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ import { join } from 'node:path';
10
7
 
11
8
  const client = new Client({
12
9
  intents: [
@@ -17,10 +14,10 @@ const client = new Client({
17
14
  ],
18
15
  });
19
16
 
20
- new CommandKit({
17
+ const commandkit = new CommandKit({
21
18
  client,
22
- eventsPath: join(__dirname, 'events'),
23
- commandsPath: join(__dirname, 'commands'),
19
+ eventsPath: join(import.meta.dirname, 'events'),
20
+ commandsPath: join(import.meta.dirname, 'commands'),
24
21
  });
25
22
 
26
- client.login(process.env.TOKEN);
23
+ await commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,10 @@
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.dev)
10
+ - [Discord](https://ctrl.lol/discord)
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'commandkit';
2
+
3
+ export default defineConfig({
4
+ src: 'src',
5
+ main: 'index.js',
6
+ });
@@ -0,0 +1,24 @@
1
+ import { SlashCommandContext, MessageCommandContext } from 'commandkit';
2
+
3
+ export const command = {
4
+ name: 'ping',
5
+ description: "Ping the bot to check if it's online.",
6
+ };
7
+
8
+ export async function chatInput(ctx: SlashCommandContext) {
9
+ const { t } = ctx.locale();
10
+
11
+ const latency = ctx.client.ws.ping ?? -1;
12
+ const response = await t('ping_response', { latency });
13
+
14
+ await ctx.interaction.reply(response);
15
+ }
16
+
17
+ export async function message(ctx: MessageCommandContext) {
18
+ const { t } = ctx.locale();
19
+
20
+ const latency = ctx.client.ws.ping ?? -1;
21
+ const response = await t('ping_response', { latency });
22
+
23
+ await ctx.message.reply(response);
24
+ }
@@ -0,0 +1,5 @@
1
+ import type { Client } from 'discord.js';
2
+
3
+ export default function log(client: Client<true>) {
4
+ console.log(`Logged in as ${client.user.username}!`);
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "command": {
3
+ "name": "ping",
4
+ "description": "Ping the bot to check if it's online."
5
+ },
6
+ "response": {
7
+ "ping_response": "The ping is `{latency}ms`."
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ process.loadEnvFile();
2
+
3
+ import { Client, IntentsBitField } from 'discord.js';
4
+ import { CommandKit } from 'commandkit';
5
+
6
+ const client = new Client({
7
+ intents: [
8
+ IntentsBitField.Flags.Guilds,
9
+ IntentsBitField.Flags.GuildMembers,
10
+ IntentsBitField.Flags.GuildMessages,
11
+ IntentsBitField.Flags.MessageContent,
12
+ ],
13
+ });
14
+
15
+ const commandkit = new CommandKit({
16
+ client,
17
+ });
18
+
19
+ commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["ES2022"],
5
+ "target": "ES2022",
6
+ "moduleResolution": "Bundler",
7
+ "module": "Preserve",
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
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
20
+ },
21
+ "include": ["src"],
22
+ "exclude": ["dist", "node_modules", ".commandkit"]
23
+ }
@@ -0,0 +1,10 @@
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.dev)
10
+ - [Discord](https://ctrl.lol/discord)
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'commandkit';
2
+
3
+ export default defineConfig({
4
+ src: 'src',
5
+ main: 'index.js',
6
+ });
@@ -0,0 +1,24 @@
1
+ import { SlashCommandContext, MessageCommandContext } from 'commandkit';
2
+
3
+ export const command = {
4
+ name: 'ping',
5
+ description: "Ping the bot to check if it's online.",
6
+ };
7
+
8
+ export async function chatInput(ctx: SlashCommandContext) {
9
+ const { t } = ctx.locale();
10
+
11
+ const latency = ctx.client.ws.ping ?? -1;
12
+ const response = await t('ping_response', { latency });
13
+
14
+ await ctx.interaction.reply(response);
15
+ }
16
+
17
+ export async function message(ctx: MessageCommandContext) {
18
+ const { t } = ctx.locale();
19
+
20
+ const latency = ctx.client.ws.ping ?? -1;
21
+ const response = await t('ping_response', { latency });
22
+
23
+ await ctx.message.reply(response);
24
+ }
@@ -0,0 +1,5 @@
1
+ import type { Client } from 'discord.js';
2
+
3
+ export default function log(client: Client<true>) {
4
+ console.log(`Logged in as ${client.user.username}!`);
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "command": {
3
+ "name": "ping",
4
+ "description": "Ping the bot to check if it's online."
5
+ },
6
+ "response": {
7
+ "ping_response": "The ping is `{latency}ms`."
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ process.loadEnvFile();
2
+
3
+ import { Client, IntentsBitField } from 'discord.js';
4
+ import { CommandKit } from 'commandkit';
5
+
6
+ const client = new Client({
7
+ intents: [
8
+ IntentsBitField.Flags.Guilds,
9
+ IntentsBitField.Flags.GuildMembers,
10
+ IntentsBitField.Flags.GuildMessages,
11
+ IntentsBitField.Flags.MessageContent,
12
+ ],
13
+ });
14
+
15
+ const commandkit = new CommandKit({
16
+ client,
17
+ });
18
+
19
+ await commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["ES2022"],
5
+ "target": "ES2022",
6
+ "moduleResolution": "Bundler",
7
+ "module": "Preserve",
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
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
20
+ },
21
+ "include": ["src"],
22
+ "exclude": ["dist", "node_modules", ".commandkit"]
23
+ }
@@ -0,0 +1,10 @@
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.dev)
10
+ - [Discord](https://ctrl.lol/discord)
@@ -1,4 +1,4 @@
1
- import 'dotenv/config';
1
+ process.loadEnvFile();
2
2
 
3
3
  import { Client, IntentsBitField } from 'discord.js';
4
4
  import { CommandKit } from 'commandkit';
@@ -13,10 +13,10 @@ const client = new Client({
13
13
  ],
14
14
  });
15
15
 
16
- new CommandKit({
16
+ const commandkit = new CommandKit({
17
17
  client,
18
18
  eventsPath: join(__dirname, 'events'),
19
19
  commandsPath: join(__dirname, 'commands'),
20
20
  });
21
21
 
22
- client.login(process.env.TOKEN);
22
+ commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["ES2022"],
5
+ "target": "ES2022",
6
+ "moduleResolution": "Bundler",
7
+ "module": "Preserve",
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
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
20
+ },
21
+ "include": ["src"],
22
+ "exclude": ["dist", "node_modules", ".commandkit"]
23
+ }
@@ -0,0 +1,10 @@
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.dev)
10
+ - [Discord](https://ctrl.lol/discord)
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'commandkit';
2
+
3
+ export default defineConfig({
4
+ src: 'src',
5
+ main: 'index.js',
6
+ });
@@ -1,12 +1,9 @@
1
- import 'dotenv/config';
1
+ process.loadEnvFile();
2
2
 
3
3
  import { Client, IntentsBitField } from 'discord.js';
4
4
  import { CommandKit } from 'commandkit';
5
5
 
6
- import { join, dirname } from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
-
9
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ import { join } from 'node:path';
10
7
 
11
8
  const client = new Client({
12
9
  intents: [
@@ -17,10 +14,10 @@ const client = new Client({
17
14
  ],
18
15
  });
19
16
 
20
- new CommandKit({
17
+ const commandkit = new CommandKit({
21
18
  client,
22
- eventsPath: join(__dirname, 'events'),
23
- commandsPath: join(__dirname, 'commands'),
19
+ eventsPath: join(import.meta.dirname, 'events'),
20
+ commandsPath: join(import.meta.dirname, 'commands'),
24
21
  });
25
22
 
26
- client.login(process.env.TOKEN);
23
+ await commandkit.start(process.env.DISCORD_TOKEN);
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["ES2022"],
5
+ "target": "ES2022",
6
+ "moduleResolution": "Bundler",
7
+ "module": "Preserve",
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
+ "jsx": "react",
18
+ "jsxFactory": "CommandKit.createElement",
19
+ "jsxFragmentFactory": "CommandKit.Fragment"
20
+ },
21
+ "include": ["src"],
22
+ "exclude": ["dist", "node_modules", ".commandkit"]
23
+ }
File without changes
File without changes