diff --git a/README.md b/README.md
index abf9041..d56e704 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ npm create @sern/bot --template=ts-esm --name="mybot"
npm create @sern/bot -- --template=ts-esm --name="mybot"
# !!!!POWERSHELL SYNTAX
-npm create @sern/bot '--' --template=ts-esm --name="mybot" --cli
+npm create @sern/bot '--' --template=ts-esm --name="mybot"
# yarn
yarn create @sern/bot --template=ts-esm --name="mybot"
@@ -44,8 +44,4 @@ pnpm create @sern/bot --template=ts-esm --name="mybot"
Currently supported template presets include:
- `ts`
-- `ts-esm`
- `js`
-- `js-esm`
-- `js+cli`
-- `ts+cli`
diff --git a/metadata/templateChoices.json b/metadata/templateChoices.json
index 01b4f06..006b96f 100644
--- a/metadata/templateChoices.json
+++ b/metadata/templateChoices.json
@@ -1,27 +1,10 @@
[
{
- "title": "Typescript with sern cli & ESM",
- "value": "ts+cli"
- },
- {
- "title": "Javascript with sern cli & ESM",
- "value": "js+cli"
- },
- {
- "title": "Typescript",
- "value": "ts"
- },
-
- {
- "title": "Typescript with ESM",
- "value": "ts-esm"
+ "title": "Typescript",
+ "value": "ts"
},
{
- "title": "Javascript",
- "value": "js"
- },
- {
- "title": "Javascript with ESM",
- "value": "js-esm"
+ "title": "Javascript",
+ "value": "js"
}
]
diff --git a/src/index.ts b/src/index.ts
index 73f463e..149d85b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -101,12 +101,6 @@ async function runInteractive() {
argv.overwrite
);
const install = await prompt([
- {
- type: 'confirm',
- name: 'cli',
- message: 'install cli? (If you installed a template with `cli`, This is required!!)\n',
- initial: true
- },
which_manager
],
{ onCancel: () => {
@@ -114,24 +108,22 @@ async function runInteractive() {
},
})
- if(install.cli) {
- const jsonDeps = JSON.parse(String(execSync('npm ls -g --json')));
- const cliVersion = jsonDeps.dependencies['@sern/cli']?.version;
- if(semver.satisfies(cliVersion, '1.x')) {
- console.log('You already have a good enough sern cli.');
- } else {
- console.log(`Installing ${magentaBright('@sern/cli')}:`)
- await new Promise((resolve, reject) => {
- const child = spawn('npm', ['install', '-g', '@sern/cli@latest'], { cwd, shell: true });
- child.on('data', (s) => console.log(s.toString()));
- child.on('error', (e) => {
- console.error(e);
- console.log(red('Something went wrong with installing. Please do it yourself.'));
- reject();
- });
- child.on('close', resolve)
- })
- }
+ const jsonDeps = JSON.parse(String(execSync('npm ls -g --json')));
+ const cliVersion = jsonDeps.dependencies['@sern/cli']?.version;
+ if(semver.satisfies(cliVersion, '1.x')) {
+ console.log('You already have a good enough sern cli.');
+ } else {
+ console.log(`Installing ${magentaBright('@sern/cli')}:`)
+ await new Promise((resolve, reject) => {
+ const child = spawn('npm', ['install', '-g', '@sern/cli@latest'], { cwd, shell: true });
+ child.on('data', (s) => console.log(s.toString()));
+ child.on('error', (e) => {
+ console.error(e);
+ console.log(red('Something went wrong with installing. Please do it yourself.'));
+ reject();
+ });
+ child.on('close', resolve)
+ })
}
await runInstall(install.manager !== 'skip', root, install.manager);
}
@@ -275,8 +267,7 @@ async function init() {
'^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$',
'g'),
"project name does not match the regular expression");
- const installCli = argv['cli'] ?? false;
- await runShort(argv.template, argv.name, installCli, argv.install);
+ await runShort(argv.template, argv.name, true, argv.install);
}
console.log(magentaBright('Done!')
diff --git a/template-js+cli/.gitignore b/template-js+cli/.gitignore
deleted file mode 100644
index 7af7f04..0000000
--- a/template-js+cli/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/node_modules
-.env
\ No newline at end of file
diff --git a/template-js+cli/README.md b/template-js+cli/README.md
deleted file mode 100644
index 872c0ab..0000000
--- a/template-js+cli/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# How to use
-
-1.) Build
-```
-npm run build
-```
-2.) Run
-```
-node .
-```
-3.) Publish
-```
-npm run commands:publish
-```
-
diff --git a/template-js+cli/package.json b/template-js+cli/package.json
deleted file mode 100644
index b2d0f2f..0000000
--- a/template-js+cli/package.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "name": "js-example",
- "version": "1.0.0",
- "private": true,
- "description": "",
- "main": "src/index.js",
- "scripts": {
- "start": "node .",
- "commands:publish": "sern commands publish"
- },
- "keywords": [
- "javascript",
- "sern",
- "discord.js"
- ],
- "dependencies": {
- "@sern/handler": "^3.0.3",
- "discord.js": "latest",
- "dotenv": "^16.3.1"
- },
- "devDependencies": {
- "@types/node": "^18.0.25"
- },
- "type": "module"
-}
diff --git a/template-js+cli/src/commands/ping.js b/template-js+cli/src/commands/ping.js
deleted file mode 100644
index 1bed7ca..0000000
--- a/template-js+cli/src/commands/ping.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { CommandType, commandModule } from '@sern/handler';
-
-export default commandModule({
- type: CommandType.Both,
- plugins: [], //optional
- description: 'A ping command',
- //alias : [],
- execute: async (ctx, args) => {
- await ctx.reply('Pong 🏓');
- },
-});
diff --git a/template-js+cli/src/index.js b/template-js+cli/src/index.js
deleted file mode 100644
index 69e328f..0000000
--- a/template-js+cli/src/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-///
-import 'dotenv/config'
-import { Client, GatewayIntentBits } from 'discord.js';
-import { Sern, single, makeDependencies } from '@sern/handler';
-
-const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMembers,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent, // Make sure this is enabled for text commands!
- ],
-});
-
-/**
- * Where all of your dependencies are composed.
- * '@sern/client' is usually your Discord Client.
- * Use this function to access all of your dependencies.
- * This is used for external event modules as well
- */
-await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
-});
-
-//View docs for all options
-Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'src/commands',
- // events: 'src/events', //(optional)
-});
-
-client.login();
diff --git a/template-js-esm/.gitignore b/template-js-esm/.gitignore
deleted file mode 100644
index 7af7f04..0000000
--- a/template-js-esm/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/node_modules
-.env
\ No newline at end of file
diff --git a/template-js-esm/README.md b/template-js-esm/README.md
deleted file mode 100644
index 4640904..0000000
--- a/template-js-esm/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# TODO
diff --git a/template-js-esm/package.json b/template-js-esm/package.json
deleted file mode 100644
index f2fefd5..0000000
--- a/template-js-esm/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "js-example",
- "version": "1.0.0",
- "description": "",
- "private": true,
- "main": "src/index.js",
- "scripts": {
- "test": "node ./src/index.js"
- },
- "keywords": [
- "javacsript",
- "sern",
- "discord.js"
- ],
- "license": "UNLICENSED",
- "dependencies": {
- "@sern/handler": "^3.0.3",
- "discord.js": "latest"
- },
- "devDependencies": {
- "@types/node": "^17.0.25"
- },
- "type": "module"
-}
diff --git a/template-js-esm/src/commands/ping.js b/template-js-esm/src/commands/ping.js
deleted file mode 100644
index 1bed7ca..0000000
--- a/template-js-esm/src/commands/ping.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { CommandType, commandModule } from '@sern/handler';
-
-export default commandModule({
- type: CommandType.Both,
- plugins: [], //optional
- description: 'A ping command',
- //alias : [],
- execute: async (ctx, args) => {
- await ctx.reply('Pong 🏓');
- },
-});
diff --git a/template-js-esm/src/index.js b/template-js-esm/src/index.js
deleted file mode 100644
index 067e083..0000000
--- a/template-js-esm/src/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-///
-
-import { Client, GatewayIntentBits } from 'discord.js';
-import { Sern, single, makeDependencies } from '@sern/handler';
-
-const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMembers,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent, // Make sure this is enabled for text commands!
- ],
-});
-
-/**
- * Where all of your dependencies are composed.
- * '@sern/client' is usually your Discord Client.
- * Use this function to access all of your dependencies.
- * This is used for external event modules as well
- */
-await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
-});
-
-//View docs for all options
-Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'src/commands',
- // events: 'src/events', //(optional)
-});
-
-client.login();
diff --git a/template-js+cli/.env.example b/template-js/.env.example
similarity index 100%
rename from template-js+cli/.env.example
rename to template-js/.env.example
diff --git a/template-js/README.md b/template-js/README.md
index 4640904..872c0ab 100644
--- a/template-js/README.md
+++ b/template-js/README.md
@@ -1 +1,15 @@
-# TODO
+# How to use
+
+1.) Build
+```
+npm run build
+```
+2.) Run
+```
+node .
+```
+3.) Publish
+```
+npm run commands:publish
+```
+
diff --git a/template-js+cli/jsconfig.json b/template-js/jsconfig.json
similarity index 100%
rename from template-js+cli/jsconfig.json
rename to template-js/jsconfig.json
diff --git a/template-js/package.json b/template-js/package.json
index 48d95be..1054475 100644
--- a/template-js/package.json
+++ b/template-js/package.json
@@ -1,23 +1,25 @@
{
"name": "js-example",
"version": "1.0.0",
- "description": "",
"private": true,
+ "description": "",
"main": "src/index.js",
"scripts": {
- "test": "node ./src/index.js"
+ "start": "node .",
+ "commands:publish": "sern commands publish"
},
"keywords": [
- "javacsript",
- "sern",
- "discord.js"
+ "javascript",
+ "sern",
+ "discord.js"
],
- "license": "UNLICENSED",
"dependencies": {
- "@sern/handler": "^3.0.3",
- "discord.js": "latest"
+ "@sern/handler": "^3.0.3",
+ "discord.js": "latest",
+ "dotenv": "^16.3.1"
},
"devDependencies": {
- "@types/node": "^17.0.25"
- }
+ "@types/node": "^18.0.25"
+ },
+ "type": "module"
}
diff --git a/template-js/src/commands/ping.js b/template-js/src/commands/ping.js
index 39ecc80..1bed7ca 100644
--- a/template-js/src/commands/ping.js
+++ b/template-js/src/commands/ping.js
@@ -1,6 +1,6 @@
-const { CommandType, commandModule } = require('@sern/handler');
+import { CommandType, commandModule } from '@sern/handler';
-exports.default = commandModule({
+export default commandModule({
type: CommandType.Both,
plugins: [], //optional
description: 'A ping command',
diff --git a/template-js/src/index.js b/template-js/src/index.js
index 290cc1f..69e328f 100644
--- a/template-js/src/index.js
+++ b/template-js/src/index.js
@@ -1,7 +1,7 @@
///
-
-const { Client, GatewayIntentBits } = require('discord.js');
-const { Sern, single, makeDependencies } = require('@sern/handler');
+import 'dotenv/config'
+import { Client, GatewayIntentBits } from 'discord.js';
+import { Sern, single, makeDependencies } from '@sern/handler';
const client = new Client({
intents: [
@@ -15,21 +15,18 @@ const client = new Client({
/**
* Where all of your dependencies are composed.
* '@sern/client' is usually your Discord Client.
- * View documentation for pluggable dependencies
+ * Use this function to access all of your dependencies.
* This is used for external event modules as well
*/
+await makeDependencies(({ add }) => {
+ add('@sern/client', single(() => client));
+});
-async function init() {
- await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
- });
+//View docs for all options
+Sern.init({
+ defaultPrefix: '!', // removing defaultPrefix will shut down text commands
+ commands: 'src/commands',
+ // events: 'src/events', //(optional)
+});
- //View docs for all options
- Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'src/commands',
- // events: 'src/events', //(optional)
- });
-}
-
-init().then(() => client.login());
+client.login();
diff --git a/template-ts+cli/.gitignore b/template-ts+cli/.gitignore
deleted file mode 100644
index c7fb7a4..0000000
--- a/template-ts+cli/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/dist
-.env
\ No newline at end of file
diff --git a/template-ts+cli/README.md b/template-ts+cli/README.md
deleted file mode 100644
index 872c0ab..0000000
--- a/template-ts+cli/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# How to use
-
-1.) Build
-```
-npm run build
-```
-2.) Run
-```
-node .
-```
-3.) Publish
-```
-npm run commands:publish
-```
-
diff --git a/template-ts+cli/package.json b/template-ts+cli/package.json
deleted file mode 100644
index 7c96e98..0000000
--- a/template-ts+cli/package.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "ts-example",
- "version": "1.0.0",
- "private": true,
- "description": "",
- "main": "dist/index.js",
- "scripts": {
- "build": "sern build",
- "start": "node .",
- "install": "sern build",
- "commands:publish": "sern commands publish"
- },
- "keywords": [
- "typescript",
- "sern",
- "discord.js"
- ],
- "dependencies": {
- "@sern/handler": "^3.0.3",
- "discord.js": "latest",
- "dotenv": "^16.3.1"
- },
- "devDependencies": {
- "@types/node": "^17.0.25",
- "typescript": "^5.0"
- },
- "type": "module"
-}
diff --git a/template-ts+cli/src/commands/ping.ts b/template-ts+cli/src/commands/ping.ts
deleted file mode 100644
index 18a7d3a..0000000
--- a/template-ts+cli/src/commands/ping.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { commandModule, CommandType } from '@sern/handler';
-
-export default commandModule({
- type: CommandType.Both,
- plugins: [],
- description: 'A ping command',
- //alias : [],
- execute: async (ctx, args) => {
- await ctx.reply('Pong 🏓');
- },
-});
diff --git a/template-ts+cli/src/index.ts b/template-ts+cli/src/index.ts
deleted file mode 100644
index f86abe2..0000000
--- a/template-ts+cli/src/index.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import 'dotenv/config'
-import { Client, GatewayIntentBits } from 'discord.js';
-import { Sern, single, makeDependencies } from '@sern/handler';
-
-const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMembers,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent, //Make sure this is enabled for text commands!
- ],
-});
-
-
-/**
- * Where all of your dependencies are composed.
- * '@sern/client' is usually your Discord Client.
- * Use this function to access all of your dependencies.
- * This is used for external event modules as well
- */
-await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
-});
-
-//View docs for all options
-Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'dist/commands',
- // events: 'dist/events', //(optional)
-});
-
-await client.login()
diff --git a/template-ts+cli/tsconfig.json b/template-ts+cli/tsconfig.json
deleted file mode 100644
index 8e3c033..0000000
--- a/template-ts+cli/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "./.sern/tsconfig.json"
-}
diff --git a/template-ts-esm/.gitignore b/template-ts-esm/.gitignore
deleted file mode 100644
index c7fb7a4..0000000
--- a/template-ts-esm/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/dist
-.env
\ No newline at end of file
diff --git a/template-ts-esm/README.md b/template-ts-esm/README.md
deleted file mode 100644
index 4640904..0000000
--- a/template-ts-esm/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# TODO
diff --git a/template-ts-esm/package.json b/template-ts-esm/package.json
deleted file mode 100644
index 51e175a..0000000
--- a/template-ts-esm/package.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "name": "ts-example",
- "version": "1.0.0",
- "description": "",
- "main": "dist/index.js",
- "scripts": {
- "build": "tsc",
- "start": "tsc && node ./dist/index.js"
- },
- "keywords": [
- "typescript",
- "sern",
- "discord.js"
- ],
- "license": "UNLICENSED",
- "dependencies": {
- "@sern/handler": "^3.0.3",
- "discord.js": "latest"
- },
- "devDependencies": {
- "@types/node": "^17.0.25",
- "typescript": "5.0"
- },
- "type": "module"
-}
diff --git a/template-ts-esm/src/commands/ping.ts b/template-ts-esm/src/commands/ping.ts
deleted file mode 100644
index 18a7d3a..0000000
--- a/template-ts-esm/src/commands/ping.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { commandModule, CommandType } from '@sern/handler';
-
-export default commandModule({
- type: CommandType.Both,
- plugins: [],
- description: 'A ping command',
- //alias : [],
- execute: async (ctx, args) => {
- await ctx.reply('Pong 🏓');
- },
-});
diff --git a/template-ts-esm/src/index.ts b/template-ts-esm/src/index.ts
deleted file mode 100644
index d7e44ea..0000000
--- a/template-ts-esm/src/index.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Client, GatewayIntentBits } from 'discord.js';
-import { Sern, makeDependencies, single } from '@sern/handler';
-
-const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMembers,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent, //Make sure this is enabled for text commands!
- ],
-});
-
-/**
- * Where all of your dependencies are composed.
- * '@sern/client' is usually your Discord Client.
- * Use this function to access all of your dependencies.
- * This is used for external event modules as well
- */
-await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
-});
-
-
-//View docs for all options
-Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'dist/commands',
- // events: 'dist/events', //(optional)
-});
-
-client.login();
diff --git a/template-ts-esm/tsconfig.json b/template-ts-esm/tsconfig.json
deleted file mode 100644
index 67cd8fd..0000000
--- a/template-ts-esm/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "compilerOptions": {
- "moduleResolution": "node",
- "resolveJsonModule": true,
- "target": "ESNext",
- "module": "ESNext",
- "outDir": "dist",
- "rootDir": "src",
- "strict": true,
- "esModuleInterop": true,
- "noImplicitAny": true,
- "strictNullChecks": true,
- "skipLibCheck": true,
- "forceConsistentCasingInFileNames": true
- }
-}
diff --git a/template-ts+cli/.env.example b/template-ts/.env.example
similarity index 100%
rename from template-ts+cli/.env.example
rename to template-ts/.env.example
diff --git a/template-ts/README.md b/template-ts/README.md
index 4640904..872c0ab 100644
--- a/template-ts/README.md
+++ b/template-ts/README.md
@@ -1 +1,15 @@
-# TODO
+# How to use
+
+1.) Build
+```
+npm run build
+```
+2.) Run
+```
+node .
+```
+3.) Publish
+```
+npm run commands:publish
+```
+
diff --git a/template-ts/package.json b/template-ts/package.json
index 1cd9328..23c392d 100644
--- a/template-ts/package.json
+++ b/template-ts/package.json
@@ -5,8 +5,10 @@
"description": "",
"main": "dist/index.js",
"scripts": {
- "build": "tsc",
- "start": "tsc && node ./dist/index.js"
+ "build": "sern build",
+ "start": "node .",
+ "install": "sern build",
+ "commands:publish": "sern commands publish"
},
"keywords": [
"typescript",
@@ -15,10 +17,12 @@
],
"dependencies": {
"@sern/handler": "^3.0.3",
- "discord.js": "latest"
+ "discord.js": "latest",
+ "dotenv": "^16.3.1"
},
"devDependencies": {
"@types/node": "^17.0.25",
"typescript": "^5.0"
- }
+ },
+ "type": "module"
}
diff --git a/template-ts/src/index.ts b/template-ts/src/index.ts
index 7499689..f86abe2 100644
--- a/template-ts/src/index.ts
+++ b/template-ts/src/index.ts
@@ -1,3 +1,4 @@
+import 'dotenv/config'
import { Client, GatewayIntentBits } from 'discord.js';
import { Sern, single, makeDependencies } from '@sern/handler';
@@ -11,23 +12,21 @@ const client = new Client({
});
-async function init() {
- /**
- * Where all of your dependencies are composed.
- * '@sern/client' is usually your Discord Client.
- * Use this function to access all of your dependencies.
- * This is used for external event modules as well
- */
- await makeDependencies(({ add }) => {
- add('@sern/client', single(() => client));
- });
+/**
+ * Where all of your dependencies are composed.
+ * '@sern/client' is usually your Discord Client.
+ * Use this function to access all of your dependencies.
+ * This is used for external event modules as well
+ */
+await makeDependencies(({ add }) => {
+ add('@sern/client', single(() => client));
+});
- //View docs for all options
- Sern.init({
- defaultPrefix: '!', // removing defaultPrefix will shut down text commands
- commands: 'dist/commands',
- // events: 'dist/events', //(optional)
- });
-}
+//View docs for all options
+Sern.init({
+ defaultPrefix: '!', // removing defaultPrefix will shut down text commands
+ commands: 'dist/commands',
+ // events: 'dist/events', //(optional)
+});
-init().then(() => client.login())
+await client.login()
diff --git a/template-ts/tsconfig.json b/template-ts/tsconfig.json
index b6cd170..8e3c033 100644
--- a/template-ts/tsconfig.json
+++ b/template-ts/tsconfig.json
@@ -1,15 +1,3 @@
{
- "compilerOptions": {
- "resolveJsonModule": true,
- "target": "ESNext",
- "module": "CommonJS",
- "outDir": "dist",
- "rootDir": "src",
- "strict": true,
- "esModuleInterop": true,
- "noImplicitAny": true,
- "strictNullChecks": true,
- "skipLibCheck": true,
- "forceConsistentCasingInFileNames": true
- }
+ "extends": "./.sern/tsconfig.json"
}